Go: Difference between revisions
(Created page with "{{DISPLAYTITLE:go}} '''#go''' (Shortened: '''/''') is a ZZT-OOP movement command which makes an object move one step. If the destination is blocked by an...") |
m (wikilink, grammar) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:go}} | {{DISPLAYTITLE:go}} | ||
'''#go''' (Shortened: '''[[Movement|/]]''') 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. | '''#go''' (Shortened: '''[[Movement|/]]''') 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. <code>#if [[contact]] go <direction></code>) 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 == | == Syntax == | ||
Line 7: | Line 9: | ||
Shortened form: <code>/<direction></code> | Shortened form: <code>/<direction></code> | ||
== #go idle quirk == | |||
If an object is commanded to <code>#go idle</code> (or <code>#go i</code>) instead of <code>/idle</code> or <code>/i</code>, 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. <code>#if [[alligned]] go idle</code>), it will not proceed any further in its code until the [[flag]] in the statement is false. This is because the code for the <code>/</code> shortcut contains a check for whether the object's changes in X and Y positions are both 0 (i.e. if it is <code>idle</code>) before attempting to move, but the code for <code>#go</code> does not. As a result, any object that uses a <code>#go idle</code> 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. | |||
{{ZZT-OOP navbox}} | {{ZZT-OOP navbox}} |
Latest revision as of 20:21, 24 August 2021
#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.
ZZT-OOP | |
---|---|
Prefixes |
|
Messages | |
Directions | |
Flags | |
Commands |