Events
Scripts can be bound to events. This page describes how to do so and which events there are.
Commands
The following commands exist to bind scripts to events:
/bindscript <eventdescriptor> <script>
- <eventdescriptor> is a dot-separated string of tokens which describes the event to bind to. See below for details.
- <script> is the name of the script, which is identical to the name of its file, without the extension. See below for details about creating scripts.
/listbindings
Lists all bound events.
/unbindscript <eventdescriptor> [<script>]
- <eventdescriptor> is a dot-separated string of tokens which describes the event from which to unbind a script, or all scripts.
- <script> is the name of the script to unbind. You may leave it out, in which case all scripts will be unbound from the specified event.
Event descriptor
The event descriptor is a dot-separated string of tokens. Each token represents an object; the first token one of the predefined context variables; each further token a property of the previously selected object. Every object has a type, which determines the properties and events it supports. These types are documented separately below. For an event descriptor, the last token must identify an event, otherwise an error will occur.
Token | Object | Type | ||||
world | The current world - undefined when using the console. | World | ||||
world.worldname | The world with the specified worldname. | World | ||||
block.blockname | The block with the specified blockname in the current world - undefined when using the console. | Block | ||||
player | The current player - undefined when using the console. | Player | ||||
player.playername | The player with the specified playername. | Player | ||||
time | Various time based events for the current world - undefined when using the console. | Time |
Events:
Token | Event | |||
command.commandname | The execution of the commandname command. Note that it may be an existing command or a new command! The command name along with all parameters provided by the sender will be passed to the script in the args context variable. Parameters containing white space or double quotes should be surrounded with double quotes (and any double quotes in them should be escaped by doubling them). | |||
idle | An event that fires for the current world whenever it becomes idle - that is when the last player logs out. Undefined when using the console. | |||
idle.delay | An event that fires for the current world delay amount of time after it becomes idle. The delay is specified as "100t", "10s" or "1m" where the number can be any number and the letter respectively signifies ticks, seconds or minutes. Undefined when using the console. |
World
Properties:
Token | Property | Type | ||||
block.blockname | The named block with the specified blockname | Block | ||||
time | Various time based events for this world. | Time |
Events:
Token | Event | |||
idle | An event that fires for this world whenever it becomes idle - that is when the last player logs out. | |||
idle.delay | An event that fires for each world delay amount of time after it becomes idle. The delay is specified as "100t", "10s" or "1m" where the number can be any number and the letter respectively signifies ticks, seconds or minutes. |
Block
Events:
Token | Event | |||
interacted | A player interacted with the block |
Player
Events:
Token | Event | |||
login | The player logs in. | |||
logout | The player logs out. |
Time
Events:
Token | Event | |||
day | The day starts (the sun has risen and it is fully light). | |||
noon | It is noon (the sun is at its highest point). | |||
dusk | The dusk starts (the sun starts to go down and it starts to become dark). | |||
night | The night starts (the sun has fully set and it is completely dark). | |||
midnight | It is midnight. | |||
dawn | The dawn starts (the moon starts to go down and it starts to become light. |
Comments