Direction modifiers: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
m (operation vs relation.)
(fixed opp cw rndne example)
 
(2 intermediate revisions by 2 users not shown)
Line 8: Line 8:


==rndp==
==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, <code>#move rndp e</code> causes the object to attempt to move one of two directions perpendicular to east, that is, randomly north or south. For more information, see [[Random directions#rndp|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, <code>#go rndp e</code> causes the object to attempt to move one of two directions perpendicular to east, that is, randomly north or south. For more information, see [[Random directions#rndp|rndp]].


==Combining Direction Modifiers==
==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 <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 cw rndne</code> would evaluate this way:


<code>
<pre>
opp ccw rndne<br>
opp cw 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}}

Latest revision as of 00:34, 22 April 2023

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, #go 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 cw rndne would evaluate this way:

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