set script command upgrade: command =[Object Command/Signal]
script =[Script Name]
Similar to the previously described set script command upgrade, except this version allows the setting of a check script.
The check script is a script that is run prior to a menu being displayed that includes the given command.
The return value of the check script determines if the given command is allowed to run or not.
If it is not allowed to run, then the option for it is greyed out in the command menu.
The possible return codes for check scripts are in the constants list available in the script editor when you pick 'Select Constant ' and are listed in the following table:
- The check script is run once for each time the menu is displayed. The status of the command is thus not checked again unless the menu is terminated and redisplayed. Bitwise OR (the | operator) this with one of the bottom four results.
- The check script is run continuously while a menu is being displayed. If the status changes, then the menu is updated while it is being displayed. Bitwise OR (the | operator) this with one of the bottom four results.
- The command is available only if the ship has any home base set.
- The command is available if the ship has a station (not another ship) set as its home base.
- The command is available.
The following is an example of a check script.
It is the script used to determine if the Navigation command, “Jump to sector” is available or not.
-] get amount of ware Jumpdrive
in cargo bay
003 * jumpdrive installed, allow command
006 * no jumpdrive but nav software mk1 is installed, disable command
Because the CmdConCheck.OneTime constant
'ed in to the returned result, this check script is only run once (just before each time the Navigation commands menu is displayed).
The script checks for the Jumpdrive ware – if it is present, the “Jump to sector” command is made available.
If it is not present, the command is disabled.
Note that when a check script puts a ship in a different sector (which will happen as soon the command menu is opened), all commands given to the ship will default to the new sector.
This is the only way to “quick select” a faraway sector without actually rewriting all scripts you want affected.