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.

TokenObjectType
worldThe current world - undefined when using the console.World
world.worldnameThe world with the specified worldname.World
block.blocknameThe block with the specified blockname in the current world - undefined when using the console.Block
playerThe current player - undefined when using the console.Player
player.playernameThe player with the specified playername.Player
timeVarious time based events for the current world - undefined when using the console.Time

Events:

TokenEvent
command.commandnameThe 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).
idleAn 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.delayAn 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:

TokenPropertyType
block.blocknameThe named block with the specified blocknameBlock
timeVarious time based events for this world.Time

Events:

TokenEvent
idleAn event that fires for this world whenever it becomes idle - that is when the last player logs out.
idle.delayAn 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:

TokenEvent
interactedA player interacted with the block

Player

Events:

TokenEvent
loginThe player logs in.
logoutThe player logs out.

Time

Events:

TokenEvent
dayThe day starts (the sun has risen and it is fully light).
noonIt is noon (the sun is at its highest point).
duskThe dusk starts (the sun starts to go down and it starts to become dark).
nightThe night starts (the sun has fully set and it is completely dark).
midnightIt is midnight.
dawnThe dawn starts (the moon starts to go down and it starts to become light.

Comments

Posts Quoted:
Reply
Clear All Quotes