Skip to reading
The Variable Designer

10. Pick the right change operation

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

Set Variable replaces the complete value. Change Variable offers a choice of operations, so it is the useful action for counters, toggles and list additions. Choose the operation according to the kind of data you are keeping.

Source table from 10. Pick the right change operation, page 17
OperationExampleResult or rule
setscore 7; set 10Replaces 7 with 10. For an Array, replaces the whole list.
addscore 7; add 1017. Adds the numeric amount.
subtractscore 7; subtract 25. No automatic minimum of zero.
multiplyscore 7; multiply 214. Numeric multiplication.
dividescore 7; divide 23.5. A divisor of zero leaves the value unchanged.
appendclues ["note"]; append "key"["note", "key"]. Adds one member to an Array.
toggleclock_wound False; toggleTrue. Use this with an intended Boolean.

Choose actions that match the meaning#

To mark a puzzle solved, Set Variable → true is usually clearer than toggle. If the player uses the solved object again, a toggle would turn the flag back off. Toggle fits a switch that is meant to alternate between on and off.

Append is an Array operation. It is not a text-joining command, and it does not prevent duplicate members. If you append an Array, the new member is that Array, nested inside the first one. To replace an entire list, choose set.

Add Score is also available as a separate action. It targets the score value and uses an integer amount. Change Variable → add lets you work with any chosen numeric variable.

The declared designer type is guidance for authoring and validation. It is not a hard lock on every runtime assignment. An action can still write text into a variable you intended to be a Number. Consistent inputs and play tests matter.

Page 17 of 37Permalink
Go to page