add doc of player.commands

This commit is contained in:
Romain Beaumont 2016-08-18 13:02:43 +02:00
parent 38b4d4cd29
commit 6040a4a12d
No known key found for this signature in database
GPG key ID: DB60E388B3BCF286

View file

@ -106,6 +106,7 @@
- [player.xp](#playerxp)
- [player.displayXp](#playerdisplayxp)
- [player.xpLevel](#playerxplevel)
- [player.commands](#playercommands)
- [Events](#events-2)
- ["connected"](#connected)
- ["spawned"](#spawned)
@ -681,6 +682,29 @@ Number from 0 to 1.0 representing the progress bar at the bottom of the player's
Level of xp the player has. Set this with player.setXpLevel()
#### player.commands
Instance of the [Command](#flying-squidcommand) class.
Here is an example to create a new command :
```js
player.commands.add({
base: 'hello',
info: 'print hello in the console',
usage: '/hello <pseudo>',
op: false,
parse(str) {
const args=str.split(' ');
if(args.length!=1)
return false;
return {pseudo:args[0]};
},
action({pseudo}) {
console.log("Hello "+pseudo);
}
});
```
### Events
#### "connected"