Skip to reading
The Variable Designer

13. Compare amounts with If Compare

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 illustrations

If Variable asks whether a value equals a chosen value. For “at least ten points”, use If Compare. The left-hand side must read the score variable, not compare the literal word score.

1. Create a visual script called Score Check, ID score_gate, with an On Interact entry.

2. Add If Compare. In Left, enter {"$var":"score"}.

3. Choose >= in Compare and enter 10 in Right.

4. Connect TRUE to a Show Message saying “You have enough points.” Connect FALSE to “You need ten points.”

5. Call the script from an interaction. Test once at score 0 and again at score 10.

Figure 18. A numeric comparison reads the live score through a $var reference. The two outputs handle the success and failure cases.

Source table from 13. Compare amounts with If Compare, page 23
EntryMeaning
{"$var":"score"}Resolve the current value of the global variable score.
"score"The literal String score. It does not fetch a variable.
10A numeric threshold.

Available comparisons include ==, !=, <, <=, > and >=. Use numbers on both sides of an amount comparison. The reference object uses one key, $var, with the exact variable ID as its value.

Page 23 of 37Permalink
Go to page