Conditions
if health <= 0 {
debug.log("Defeated")
} else if health < 25 {
debug.log("Low health")
} else {
debug.log("Ready")
}
Only the first matching branch runs.
For loops
Use for to visit values in a basket.
for item in ["Sword", "Potion"] {
debug.log(item)
}
While loops
Use while to repeat while a condition is true.
count = 0
while count < 3 {
count += 1
debug.log(count)
}
A loop must finish or pause. An endless loop without a pause can exceed the script execution limit. Prefer events for work triggered by gameplay.
Return
Use return to leave a function. See Functions.