Skip to reading
PCA Script Programming

8. Comparisons, logic and precedence

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
Source table from 8. Comparisons, logic and precedence, page 15
OperatorMeaning
==, isEqual
!=, is notNot equal
<, is less thanLess than
<=, is at mostLess than or equal
>, is greater thanGreater than
>=, is at leastGreater than or equal
andBoth tests true; stops early on false
orEither test true; stops early on true
notReverse a test
player has keyInventory possession, not array membership
objects.archive_door existsThe referenced record exists
Code example
function run()
    let power = true
    let code_entered = false
    let override = true
    let allowed = power and (code_entered or override)
    return allowed
end

From 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.

Page 15 of 357Permalink
Go to page