[WiP][General Information] Syntax used in this reference

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Post Reply
User avatar
ScRaT_GER
Posts: 1958
Joined: Tue, 8. Jan 08, 19:19
x3tc

[WiP][General Information] Syntax used in this reference

Post by ScRaT_GER » Sat, 2. Oct 10, 16:31

Preface

In this reference we use a consistent syntax for all commands. If some commands do not coincide completely with the meaning of an element described here, it will be pointed out in the corresponding thread.


List of syntactic elements

<RetVar/IF> = This statement precedes a command returning a value, which can be either saved in a variable or used as a condition.

Example
<RetVar/IF> <RefObj> -> get amount of ware <Var/Ware> in cargo bay
  • $amount = $ship -> get amount of ware $ware in cargo bay - saves amount in variable $amount
  • if $ship -> get amount of ware $ware in cargo bay - uses the commands return value for an if-statement
  • while not $ship -> get amount of ware $ware in cargo bay - uses the commands return value as a loop condition
<RetVar/IF/START> = This statement only adds the START option to the previously decsribed statement. When you choose START, execution of the script doesn't halt until the command returns a value, but simply continues.
If the START option is available, you can also choose to discard the return value but wait until the command returns nevertheless (see example).

Example
<RetVar/IF/START> speak array: <Value> prio=<Var/Number>
  • START speak array $name prio=$prio - starts the command and directly continues execution, even though the command is actually still running
  • $someVariable = speak array: $name prio=$prio - waits until the command returns and saves the returned value in the variable $someVariable
  • = speak array: $name prio=$prio - waits until the command returns but discards its return value
<Var/XYZ> = Here you can either use a variable or a constant of type XYZ.

Example
<RetVar> = convert number <Var/Number> to string
  • $numberString = convert number 42 to string - 42 is a constant number, entered directly
  • $numberString = convert number $someNumber to string - $someNumber is a variable which holds a number
<Value> = Can take any value (i.e. a variable holding a ship, a number or a string). Normally the requested datatype can be deduced from the context.

Example:
<RetVar/IF/START> speak array: <Value> prio=<Var/Number>
  • = speak array: $myArray prio=$prio - $myArray is a variable of type array and can thus be processed by the command
  • = speak array: 124 prio=$prio - 124 is a number literal, which can be entered, but cannot be used for the command

[Note to others: If there are more elements to be included, please post them here.
Btw: How are constants like object classes marked (or should they be marked at all)? The Escriptor uses curly braces, e.g. {SIGNAL_LOADWARE}, which I find quite clear, but they might be confusing to beginners, since the ingame SE doesn't display them.]

Post Reply

Return to “MSCI Reference”