Skip to content

Player Input

inventivetalent edited this page May 17, 2016 · 1 revision

Player Input

Additionally to the click function, you can request more input information for players.

Cursor Position

The Cursor Position represents the x|y coordinate a player is looking at on a menu.

You can retrieve it by calling this function:

menu.getCursorPosition(player);

Note that it can return null, which indicates that the specified players is

  • null
  • not online
  • in a different world
  • not looking at the menu

Keyboard Input (Chat)

You can request a text input from players by calling this function:

menu.requestKeyboardInput(player, callback, [cancel]);
  • callback must be a function. It will be called with the player's message.
  • cancel specifies whether the player's message will be cancelled from reaching the actual chat. Default to true.

Command Input

Similar to text input, you can also request commands from players by calling this function:

menu.requestCommandInput(player, callback, [cancel]);
  • callback must be a function. It will be called with the executed command.
  • cancel whether the executed command will be cancelled. Defaults to true.

Movement Input

Now, this is a bit more complicated.
You can request a player's movement actions by calling this function:

menu.requestMovementInput(player, callback, [cancel]);
  • callback function
function(type, amount, difference){}
* `type` is the direction (e.g. `forward`, `left`, `up`)
* `amount` is how much the player moved
* `difference` is the exact movement difference, containing `x`,`y`,`z`,`pitch`,`yaw`  
  • callback object
{
   forward: function(amount, difference) {

   },
   up: function(amount) {

   },
   pitch: function(amount) {

   }
}

Clone this wiki locally