From a314bf849f1bb949e6008df63e68274007121140 Mon Sep 17 00:00:00 2001 From: walterhiggins Date: Sat, 26 Apr 2014 20:31:52 +0100 Subject: [PATCH] tidy up docs on events-helper module. --- docs/API-Reference.md | 15 +++++++++------ src/generateEventsHelper.js | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/API-Reference.md b/docs/API-Reference.md index 898bb6b..d351a77 100644 --- a/docs/API-Reference.md +++ b/docs/API-Reference.md @@ -929,23 +929,26 @@ ScriptCraft uses Java's [String.format()][strfmt] so any string substitution ide [webcons]: https://developer.mozilla.org/en-US/docs/Web/API/console ## Events Helper Module -The Events helper module provides a suite of functions one for each possible event. -For example, the blockBreak function in turn calls events.on(org.bukkit.event.block.BlockBreakEvent, callback, priority) -This module is a convenience wrapper for easily add new event handlers. +The Events helper module provides a suite of functions - one for each possible event. +For example, the events.blockBreak() function is just a wrapper function which calls events.on(org.bukkit.event.block.BlockBreakEvent, callback, priority) +This module is a convenience wrapper for easily adding new event handling functions in Javascript. +At the in-game or server-console prompt, players/admins can type `events.` and use TAB completion +to choose from any of the approx. 160 different event types to listen to. + ### Usage events.blockBreak(function(evt){ evt.player.sendMessage("You broke a block!"); }); -... which is just a shorter way of writing ... +... which is just a shorter and less error-prone way of writing ... events.on("block.BlockBreakEvent",function(evt){ evt.player.sendMessage("You broke a block!"); }); -The crucial difference is that the events module will have functions for each -of the built-in events so tab-completion will help +The crucial difference is that the events module now has functions for each +of the built-in events. The functions are accessible via tab-completion so will help beginning programmers to explore the events at the server console window. ### events.worldUnload() diff --git a/src/generateEventsHelper.js b/src/generateEventsHelper.js index 86fe1b0..3c398ef 100644 --- a/src/generateEventsHelper.js +++ b/src/generateEventsHelper.js @@ -8,23 +8,26 @@ var File = java.io.File, var content = [ '/*********************', '## Events Helper Module', - 'The Events helper module provides a suite of functions one for each possible event.', - 'For example, the blockBreak function in turn calls events.on(org.bukkit.event.block.BlockBreakEvent, callback, priority)', - 'This module is a convenience wrapper for easily add new event handlers.', + 'The Events helper module provides a suite of functions - one for each possible event.', + 'For example, the events.blockBreak() function is just a wrapper function which calls events.on(org.bukkit.event.block.BlockBreakEvent, callback, priority)', + 'This module is a convenience wrapper for easily adding new event handling functions in Javascript. ', + 'At the in-game or server-console prompt, players/admins can type `events.` and use TAB completion ', + 'to choose from any of the approx. 160 different event types to listen to.', + '', '### Usage', '', ' events.blockBreak(function(evt){ ', ' evt.player.sendMessage("You broke a block!"); ', ' });', '', - '... which is just a shorter way of writing ...', + '... which is just a shorter and less error-prone way of writing ...', '', ' events.on("block.BlockBreakEvent",function(evt){ ', ' evt.player.sendMessage("You broke a block!");', ' });', '', - 'The crucial difference is that the events module will have functions for each ', - 'of the built-in events so tab-completion will help ', + 'The crucial difference is that the events module now has functions for each ', + 'of the built-in events. The functions are accessible via tab-completion so will help ', 'beginning programmers to explore the events at the server console window.', '', '***/'