Events
Triggerable occurrences based on external factors.
The event system is a helpful alternative for Skript implementations in domains where triggers need to be run based on regular circumstances.
Event triggers are not unique and will be called across all scripts, with certain pre-provided values.
The purpose of the event system is to act as a 'watcher' for state changes.

Event Structure

The basic event structure looks similar to a no-parameters function. The my event part would be replaced with the event's syntax name.
1
on my event:
2
trigger:
3
print "Event has happened."
Copied!
This is an example of the on any [script] load event, which is triggered whenever a script is loaded into the environment.
1
on any script load:
2
trigger:
3
print "A script was loaded."
Copied!
Unlike functions, a single script can contain duplicate event receivers.
1
on any load:
2
trigger:
3
print "A script was loaded."
4
5
on any load:
6
trigger:
7
print "Hello I am a message."
Copied!

Event Values

Events can provide special values related to this specific event. These are found as special properties of the event object, accessible via event-thing.
1
on any script load:
2
trigger:
3
print "A script was loaded."
4
print "Its name is " + event-name
5
print "Its path is " + event-script
Copied!
Some events might provide changeable values.
1
set event-thing to {value}
Copied!

Special Events

Some events may have special behaviour defined by their providing library.
The load event triggers only in the script that is loaded, for example.
1
on script load:
2
trigger:
3
print "This particular script was loaded."
Copied!
The load event is different from the any load event!
Last modified 2mo ago