Signals allow you to react on events in the universe in a lightweight way. Signals are always associated with the object, which emitted the signal and they pass specific arguments to the scripts they are connected to.
When you connect a script to a certain signal, you also assign a priority, the script should be called with (see <RefObj> connect ship command/signal <Object Command/Signal> to script <Script Name> with prio <Var/Number>).
Thus the called script obbeys the normal iterrupt rules:
- if the priority is lower or equal to the one of the currently running script on the corresponding task, it doesn't interrupt this script
- if the priority is higher, execution of the currently running script on the corresponding task is interrupted, until the interrupting script returns
In the following section the signals will be explained in more detail. For every signal their attributes will be listed, along with the conditions which must be met for the signal to be emitted. Additionally possible uses are listed.
A signals attributes take the following form:
SIGNAL_NAME = The name of the signal, always uppercase letters, beginning with SIGNAL_SIGNAL_NAME
Task: P / S
Passed arguments: <Args>
P = Task of script attached to the signal, when signal is a primary signal
S = Task of script attached to the signal, when signal is a secondary signal
<Args> = List of arguments, which are passed to the attached script.
Signal reference
SIGNAL_ATTACKED
Task: 0 / 18
Passed arguments:
- 1: Var/Ship/Station - attacker - object which attacked [THIS]
- 2: Var/Number - action - action [THIS] is currently performing (see also Actions)
The signal is not emitted constantly, when a ship is attacked, but it has a cool down phase of a few seconds (maybe 1-2 seconds). This means that you cannot use the signal to react to single shots, which wouldn't be desirable anyways, because of the performance impact of runnig one or more scripts every time a ship is hit.
Possible uses: Any fight script
SIGNAL_BUYWARE
Task: 0 / 18
Passed arguments:
- 1: Var/Ship/Station - trading partner (can be ship or station, depending on the associated object)
- 2: Var/Ware - bought ware
- 3: Var/Number - bought amount
- 4: Var/Number - price of single ware (not total price)
- 5: Value - Special*
Conditions: This signal is emitted when an object buys a ware. It only buys a ware, if credits are transacted, so the signal will not be emitted if the player loads wares onto the playership at his own station. See SIGNAL_LOADWARE for this case.
Possible uses: Logging scripts, custom trade scripts
SIGNAL_SELWARE
Equivalent to SIGNAL_BUYWARE.
SIGNAL_LOADWARE
Task: 0 / 18
Passed arguments:
- 1: Var/Ship/Station - trading partner (can be ship or station, depending on the associated object)
- 2: Var/Ware - bought ware
- 3: Var/Number - bought amount
Conditions: This signal is emitted when an objects loads a ware. It only loads a ware, if no credits are transacted, so the signal will no be emitted if the player buys a ware at a station. See SIGNAL_BUYWARE for this case.
Possible uses: Loggin scripts, custom trade scripts
SIGNAL_UNLOADWARE
Equivalent to SIGNAL_LOADWARE.
SIGNAL_DOCKED
Task: 0 / 18
Passed arguments:
- Var/Ship/Station - object [THIS] docked at
- a) It fires twice
b) Not all connected scripts are run, because when docking with the playership all scripts running on task 0 are killed
c) You can create a very strange hack using a secondary signal, which enables you to run a script on task 0, while you're docked and while task 0 should normally not run any script. This script can even keep on running on task 0 while you still can control the ship completely, which shouldn't be possible, when task 0 is running. Since this is a bug, you'll have to research yourself if you want to know more about it.
TO DO:
List all signals and gather all information.
Add examples for every signal.
Link to related topics.