set script command upgrade: command =[Object Command/Signal] upgrade =[Var/Ware] scri

Previous: [RetVar] = get script command upgrade: command =[Object Command/Signal] Commands/Signals Next: set ship command preload script: command = [Object Command/Signal] script = [Script N
This page is a chapter in the book Commands/Signals.
set script command upgrade: command =[Object Command/Signal] upgrade =[Var/Ware] 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:






Constant
Description

CmdConCheck.OneTime
  • 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.


CmdConCheck.Infinite
  • 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.


CmdConCheck.NeedHomeBase
  • The command is available only if the ship has any home base set.


CmdConCheck.NeedHomeStation
  • The command is available if the ship has a station (not another ship) set as its home base.


CmdConCheck.Available
  • The command is available.


CmdConCheck.Disabled
  • The command is disabled.




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.

001 $flags = [CmdConCheck.OneTime]
002 if $ship -] get amount of ware Jumpdrive in cargo bay
003 * jumpdrive installed, allow command
004 $flags = $flags | [CmdConCheck.Available]
005 else
006 * no jumpdrive but nav software mk1 is installed, disable command
007 $flags = $flags | [CmdConCheck.Disabled]
008 end
009 return $flags


Because the CmdConCheck.OneTime constant is 'OR'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.

Commands/Signals - Contents


Tags for this Page

Posting Permissions

Posting Permissions
  • You may not create new articles
  • You may not edit articles
  • You may not protect articles
  • You may not post comments
  • You may not post attachments
  • You may not edit your comments