Script:Events: Difference between revisions

From Arx Libertatis Wiki
Jump to navigation Jump to search
(Created page with "Events are entry points of entity scripts. They are sent by the game engine or by other scripts using the {{Command|sendevent}} command. While the engine defines some event na...")
 
No edit summary
Line 20: Line 20:
Events sent by the game engine are usually executed synchronously although there are some exceptions. Events sent by scripts are always executed asynchronously.
Events sent by the game engine are usually executed synchronously although there are some exceptions. Events sent by scripts are always executed asynchronously.


Events are first executed in the entity instance script. Commands are executed after <code>on eventname</code> until a {{Command|accept}} or {{Command|refuse}} command is reached. {{Command|refuse}} ends event execution while {{Command|refuse}} allows execution to continue after <code>on eventname</code> in the entity class script until a {{Command|accept}} or {{Command|refuse}} command is reached there. If a script does not have a <code>on eventname</code> block, the event is always accepted.
Events are first executed in the entity instance script. Commands are executed after <code>on eventname</code> until a {{Command|accept}} or {{Command|refuse}} command is reached. {{Command|refuse}} ends event execution while {{Command|accept}} allows execution to continue after <code>on eventname</code> in the entity class script until a {{Command|accept}} or {{Command|refuse}} command is reached there. If a script does not have a <code>on eventname</code> block, the event is always accepted.


For events sent by the game engine, ending the event with {{Command|accept}} or {{Command|refuse}} sometimes also determines some further engine behavior. For events send by entity scripts the result is not returned to the sender.  
For events sent by the game engine, ending the event with {{Command|accept}} or {{Command|refuse}} sometimes also determines some further engine behavior. For events send by entity scripts the result is not returned to the sender.  

Revision as of 23:52, 14 April 2020

Events are entry points of entity scripts. They are sent by the game engine or by other scripts using the sendevent command. While the engine defines some event names, entity scripts can use arbitrary names for custom events.

Syntax

on eventname {
  ...
  accept|refuse
}

Sender

Events always have a sender associated by them. The entity ID of the sender is available in the read-only ^sender script variable.

Target

Scripts can be sent to a single target or multiple targets matching some criteria using the sendevent command but are always executed independently for each target.

Execution

Events sent by the game engine are usually executed synchronously although there are some exceptions. Events sent by scripts are always executed asynchronously.

Events are first executed in the entity instance script. Commands are executed after on eventname until a accept or refuse command is reached. refuse ends event execution while accept allows execution to continue after on eventname in the entity class script until a accept or refuse command is reached there. If a script does not have a on eventname block, the event is always accepted.

For events sent by the game engine, ending the event with accept or refuse sometimes also determines some further engine behavior. For events send by entity scripts the result is not returned to the sender.

Parameters

Events can have up to three parameters which can be accessed using the special read-only script variables as Template:Text using ^$param1, ^$param2 and ^$param3, as Template:Real using ^&param1, ^&param2 and ^&param3 or as int using ^#param1, ^#param2 and ^#param3.