8. Comparisons, logic and precedence
| Operator | Meaning |
|---|---|
| ==, is | Equal |
| !=, is not | Not equal |
| <, is less than | Less than |
| <=, is at most | Less than or equal |
| >, is greater than | Greater than |
| >=, is at least | Greater than or equal |
| and | Both tests true; stops early on false |
| or | Either test true; stops early on true |
| not | Reverse a test |
| player has key | Inventory possession, not array membership |
| objects.archive_door exists | The referenced record exists |
function run()
let power = true
let code_entered = false
let override = true
let allowed = power and (code_entered or override)
return allowed
endFrom weaker to stronger: or; and; comparisons and has; + -; * / %; unary not + -; property, index and call expressions. Parentheses are cheap insurance. not a == b is easier to understand when written not (a == b).
Use contains(text, needle) for text searches. The ordinary PCA parser does not provide Python’s in expression, a general array contains operator, or C-style && and ||. To test whether an array contains an item, loop through it and compare each value.
