triggers
copyon
Takes: trigger (word) | turtle (word)
Returns: none
Copies a trigger from the calling turtle to the target turtle. See on, defineon
copyon "trigger "turtle
defineon
Takes: name (word) | [type queue [params] [code line 1] [code line 2…]] (list)
Returns: none
Defines a trigger in the calling turtle. See example for syntax. See on, texton
defineon "trigger [paddle block [] [show :trigger]]
eraseon
Takes: name (word)
Returns: none
Erases the trigger of the specified name in the calling turtle. See on
eraseon "trigger
listons
Takes: none
Returns: none
Displays a list of the calling turtle’s triggers. See on
listons
notriggers
Takes: none
Returns: none
Disables trigger execution in the calling turtle. See triggers
notriggers
off
Takes: none
Returns: none
Causes the trigger executing off to become disabled. It will finish executing, but will not fire again, unless re-enabled via reset or toggle. See on
off
on
Takes: name (word) | type (word) | queuetype (word) [parameters]
Returns: none
Triggers allow various conditions to be detected by the underlying engine, triggering code to be executed. ON triggers are formatted similar to TO procedures, and similarly stand alone inside a turtle’s workspace. The first parameter provided to a trigger is its unique name, the second the type, the third the queue type, which can be one of noqueue (the trigger fires if the condition is true regardless of if the trigger is already executing), queue (the triggers ‘stack up’ and execute sequentially), uqueue (‘unique’ triggers queue), unoqueue (unique triggers without queueing), once (only executes once) or block (while executing, ignores subsequent triggers).
The parameter list to be provided depends on the trigger type. Triggers pass values to the code they execute in a container with the same name as the trigger (eg if the trigger is named button, the state is passed into the code in the container named :button). Triggers are enabled automatically on reset, and can be disabled by calling either 'off' from inside the trigger, or by using the toggle primitive. All triggers are disabled if the user presses the escape key, or the finish command is executed. See off, toggle, finish
Currently, there are the following trigger types:
* keyp, which triggers on keypress, takes a list of keys as its argument, which can be an empty list and will cause keyp to trigger on any keypress
* buttonp, which triggers on mouse / gamepad button press, which takes a single numerical argument (see buttonp) or an empty list, which will trigger on any button, and returns the numerical identifier of the button pressed
* paddle, which triggers on mouse / paddle movement, and passes the two paddle values (0-255) as a list, takes no arguments (empty list [])
* mouse, which triggers on mouse / paddle movement, and passes the two mouse co-ordinates (0-100) as a list, takes no arguments []
* reset / systemreset, which trigger on reset and system reset respectively, take no arguments []
* flag, which triggers on either a press of the flag button (web) or by calling the flag command. The flag trigger calls a finish, then enables all of the other triggers. The flag trigger executes as 'archon', the console worker, and takes no arguments []
* nearmissile, which triggers when a missile of a specified 'class' is within a specified distance of the turtle that owns the trigger, takes a list with the first value identifying the class, and the second value identifying the distance, and passes the name of the missile that triggered it. See newmissile
Note that containers created inside of triggers are locally scoped by default, and will need to be changed to global to be used as global containers. See local, global
See triggers, notriggers, eraseon, listons, ons, onp, defineon, texton, copyon, saveon
on mytrigger keyp noqueue [a]
on boom nearmissile queue [trident 20]
ons
Takes: none
Returns: list
Returns a list of the calling turtle’s currently defined triggers. See on
show ons
saveon
Takes: trigger | name
Returns: none
Saves the specified trigger using the given name
saveon "trigger "filename
texton
Takes: name (word)
Returns: list
Returns a list containing the contents of the specified trigger in the calling turtle. See defineon, on
show texton "trigger
[paddle block [] [show :trigger]]
toggle
Takes: name (word)
Returns: none
Disables specified calling turtle’s trigger if enabled, or enables it if it is disabled. See on, off
toggle "trigger
triggers
Takes: none
Returns: none
Enables trigger execution in the calling turtle. See notriggers
triggers