Basic directions are all that are left after the compiler has finished processing rules. They are Up, Down, Left, Right and Action. During the movement phase (after all the non-late rules have been executed), the first four of these will cause the Player(s) to move. Then all movements are removed and the late rules are executed.
There are two other kinds of directions: relative and shorthand. Both kinds get compiled into basic directions.
The relative directions are ^ > v <, parallel and perpendicular. Relative directions rotate along with their pattern. This:
[ > Player | Crate ] -> [ > Player | > Crate ]
gets compiled to the following set of rules:
UP [ UP player | crate ] -> [ UP player | UP crate ]
DOWN [ DOWN player | crate ] -> [ DOWN player | DOWN crate ]
LEFT [ LEFT player | crate ] -> [ LEFT player | LEFT crate ]
RIGHT [ RIGHT player | crate ] -> [ RIGHT player | RIGHT crate ]
You can restrict patterns so that they're only matched in a particular direction (by default, when the interpreter tries to find places to apply to rule, it tries all four rotations of it). To implement gravity, we could do
DOWN [ stationary Object ] -> [ > Object ]
Which compiles to
DOWN [ stationary Object ] -> [ DOWN Object ]
It would probably have been simpler to write the rule as
[ stationary Object ] -> [ DOWN Object ]
which is the same thing.
Another good illustration of why rule direction might be important would be if you're making a word game.
[ C | A | T ] -> WIN
would look for words in all four directions, so TAC would also match this rule. To fix it, you would restrict the rule to read left-to-right as follows:
Editright [ C | A | T ] -> WIN
Huzzah!
The shortcut directions are horizontal, vertical, orthogonal and stationary.
If you want something that moves horizontally when you move horizontally, but ignores you otherwise, do this:
[ Horizontal Player ] [ Crate ] -> [ Horizontal Player ] [ Horizontal Crate ]
and get this:
(Vertical is also a keyword that you can use).
Vertical and horizontal are both keywords, but is there a way of reducing the following to a single instruction?
[ ^ Player | Crate ] -> [ ^ Player | ^ Crate ]
[ v Player | Crate ] -> [ v Player | v Crate ]
There is, and it's this:
[ Perpendicular Player | Crate ] -> [ Perpendicular Player | Perpendicular Crate ]
Parallel means what you think it might. Orthogonal means all four directions, but not including Action.
Tip: if you don't know what something does in the examples (or in your own code 😆), it can be helpful to add the debug flag to the prelude to see how the compiler interprets it. Or you can just click on the debug button in the editor console.