Skip to content

Commit

Permalink
tab-completion using a callback
Browse files Browse the repository at this point in the history
  • Loading branch information
walterhiggins committed Jun 14, 2014
1 parent e0acaed commit 8c3c7d6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/js/lib/scriptcraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ The `command()` function is used to expose javascript functions for use by non-o
* params : An Array of type String - the list of parameters passed to the command.
* sender : The [CommandSender][bukcs] object that invoked the command (this is usually a Player object but can be a Block ([BlockCommandSender][bukbcs]).
* options (Array - optional) : An array of command options/parameters which the player can supply (It's useful to supply an array so that Tab-Completion works for the `/jsp ` commands.
* options (Array|Function - optional) : An array of command options/parameters which the player can supply (It's useful to supply an array so that Tab-Completion works for the `/jsp ` commands. If a function is supplied instead of an array then the function will be invoked at TAB-completion time and should return an array of strings.
* intercepts (boolean - optional) : Indicates whether this command can intercept Tab-Completion of the `/jsp ` command - advanced usage - see alias/alias.js for example.
#### Example
Expand All @@ -316,6 +316,17 @@ The `command()` function is used to expose javascript functions for use by non-o
/jsp boo Hi!
> Hi!
To use a callback for options (TAB-Completion) ...
function boo( params, sender ) {
var receiver = server.getPlayer( params[0] );
if ( receiver ){
receiver.sendMessage( sender.name + ' says boo!');
}
}
command( boo, bukkit.playerNames );
See chat/colors.js or alias/alias.js or homes/homes.js for more examples of how to use the `command()` function.
### setTimeout() function
Expand Down

0 comments on commit 8c3c7d6

Please sign in to comment.