Direction modifiers: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
m (operation vs relation.)
m (code formatting!)
Line 13: Line 13:
Multiple direction modifiers can be combined in a single line. Lines written this way will cause the object to treat each modifier as "modifying" the rest of the written direction, so that it is "evaluated" in pairs from right-to-left. As a concrete example, the following combination <code>opp cw n</code> evaluates like this:
Multiple direction modifiers can be combined in a single line. Lines written this way will cause the object to treat each modifier as "modifying" the rest of the written direction, so that it is "evaluated" in pairs from right-to-left. As a concrete example, the following combination <code>opp cw n</code> evaluates like this:


<code>
<pre>
opp cw n<br>
opp cw n
= opp (cw n)<br>
= opp (cw n)
= opp e<br>
= opp e
= w
= w
</code>
</pre>


And <code>opp ccw rndne</code> would evaluate thusly:
And <code>opp ccw rndne</code> would evaluate this way:


<code>
<pre>
opp ccw rndne<br>
opp ccw rndne
= opp (cw (randomly n or e))<br>
= opp (cw (randomly n or e))
= opp (randomly e or s)<br>
= opp (randomly e or s)
= randomly w or n
= randomly w or n
</code>
</pre>


{{ZZT-OOP navbox}}
{{ZZT-OOP navbox}}

Revision as of 02:53, 10 February 2021

In ZZT-OOP, a direction modifier is a word that prefixes a direction to create a new direction. If you like, you may think of them (in math terms) as relations which take a given "input" direction and produce an "output." They are explained in detail below.

cw and ccw

cw and ccw are ZZT-OOP direction modifiers which modify the direction clockwise and counter-clockwise, respectively. For example, cw n evaluates to e, but ccw n evaluates to w.

opp

opp is a ZZT-OOP direction modifier which evaluates to the exact opposite of the given direction. For example, opp n evaluates to s.

rndp

rndp is a ZZT-OOP direction modifier which causes the object to choose a random direction perpendicular to the succeeding direction, rather than simply use the succeeding direction. For example, #move rndp e causes the object to attempt to move one of two directions perpendicular to east, that is, randomly north or south. For more information, see rndp.

Combining Direction Modifiers

Multiple direction modifiers can be combined in a single line. Lines written this way will cause the object to treat each modifier as "modifying" the rest of the written direction, so that it is "evaluated" in pairs from right-to-left. As a concrete example, the following combination opp cw n evaluates like this:

opp cw n
= opp (cw n)
= opp e
= w

And opp ccw rndne would evaluate this way:

opp ccw rndne
= opp (cw (randomly n or e))
= opp (randomly e or s)
= randomly w or n