Choices

Often gear pieces exist in different quality levels, called “Rating”. In Commlink this is modelled using choices.

<item avail="3" price="250" id="medkit" subtype="BIOTECH" type="BIOLOGY"> <choices> <choice uuid="c2d17c87-1cfe-4355-9877-a20fe09c170d" type="ITEM_ATTRIBUTE" ref="RATING" options="1,2,3,4,5,6"/> </choices> </item>

The block above defines an item with the identifier “medkit”, then when added to the inventory prompts the user to make a choice for the RATING from one of the options 1-6.

Variables and Formulas

The example above has the same price for the item, no matter what rating is selected. To have the selection influence other item attributes, you can refer to it by using “$”, directly followed by the item attribute identifer ($RATING in this case). You can use it in basic formulas (addition,substraction,division,multiplication).

<item avail="3" price="250" id="medkit" subtype="BIOTECH" type="BIOLOGY" count="y"> <choices> <choice uuid="66b37416-6996-48b8-87f0-17b28dc44df1" type="ITEM_ATTRIBUTE" ref="RATING" options="1,2,3,4,5,6"/> </choices> <attrdef id="PRICE" value="$RATING*250"/> </item>

The price tag in the first line is not necessary anymore, since it is overwritten by the attribute definition line.

As seen below, formulas can have multiple operators.

<item avail="3" price="10" id="tranq_patch" subtype="SLAP_PATCHES" type="BIOLOGY" count="y"> <choices> <choice uuid="66b37416-6996-48b8-87f0-17b28dc44df1" type="ITEM_ATTRIBUTE" ref="RATING" options="1,2,3,4,5,6,7,8,9,10,11,12"/> </choices> <attrdef id="PRICE" value="$RATING*$RATING*10"/> </item>

Variables and formulas are only valid in <attrdef> elements.

Variable Scope

The character before the variable names defines the scope in which the variable will be resolved.

$

Environment in which to look up the value

$

Environment in which to look up the value

$

Resolved in the item itself

$$

Resolved in the parent item. (Not really functional yet)

$&

Resolved in the character