13. Compare amounts with If Compare
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.
| Entry | Meaning |
|---|---|
| {"$var":"score"} | Resolve the current value of the global variable score. |
| "score" | The literal String score. It does not fetch a variable. |
| 10 | A 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.
