go

From Wiki of ZZT
Jump to navigation Jump to search

#go (Shortened: /) is a ZZT-OOP movement command which makes an object move one step. If the destination is blocked by an obstacle, the object will wait until the path is clear before stepping into the spot and continuing on with program execution.

If a #go statement is used at the end of an #if statement (e.g. #if contact go <direction>) and the object is obstructed in that direction, it will wait until either the obstacle is cleared away or the flag in the statement is false. In the latter case, the object will stop its attempt to move and skip to the next command.

Syntax

Full form: #go <direction>

Shortened form: /<direction>

#go idle quirk

If an object is commanded to #go idle (or #go i) instead of /idle or /i, it will become trapped in an infinite loop, unable to progress the instruction pointer to the next command. If this command results from an if statement that is true (e.g. #if alligned go idle), it will not proceed any further in its code until the flag in the statement is false. This is because the code for the / shortcut contains a check for whether the object's changes in X and Y positions are both 0 (i.e. if it is idle) before attempting to move, but the code for #go does not. As a result, any object that uses a #go idle command will detect a non-walkable tile at its own location, attempt to push itself to no avail, and then assume it is blocked by an obstacle, pausing execution.