Difference between revisions of "Manual:DIL Manual/exit to"
Jump to navigation
Jump to search
(Created page with "= exit_to = The '''exit_to''' field is a read-only array field available on room units that provides access to the destination rooms for each direction exit. == Syntax == r...") |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
= exit_to = | = exit_to = | ||
| + | '''Field''' (unitptr, read-only; units: rooms). | ||
| − | + | room.exit_to[dir] : unitptr | |
| − | + | The room that the exit in direction <code>dir</code> leads to, or null when the room has no exit that way. <code>dir</code> is a direction from vme.h: <code>NORTH</code> (0), <code>EAST</code>, <code>SOUTH</code>, <code>WEST</code>, <code>UP</code>, <code>DOWN</code>, <code>NORTHEAST</code>, <code>NORTHWEST</code>, <code>SOUTHEAST</code>, <code>SOUTHWEST</code> (9); <code>MAX_EXIT</code> is the last. | |
| − | |||
| − | == | + | == Notes == |
| − | + | * It fails when the unit is not a room (an object, a character, null) and when <code>dir</code> is outside 0 to <code>MAX_EXIT</code>. A failed value is false in an <code>if</code>, so <code>if (room.exit_to[dir])</code> is a safe test. | |
| − | + | * It can't be assigned (vmc: "Illegal lvalue"). Make or change exits with [[Manual:DIL Manual/setroomexit()|setroomexit()]]. | |
| − | + | * Fields can be read on the result directly: <code>self.outside.exit_to[dir].movement</code> works. | |
| − | + | * To move an NPC through an exit, use <code>exec("north", self)</code> (an ordinary move, with its messages and checks) rather than <code>link(self, room.exit_to[NORTH])</code>. | |
| − | |||
| − | == | + | == Example == |
| − | { | + | <pre> |
| − | + | dilbegin string exit_list(room : unitptr); | |
| − | + | var | |
| − | + | dir : integer; | |
| − | + | sl : stringlist; | |
| + | buf : string; | ||
| + | code | ||
| + | { | ||
| + | sl := DIR_SL_SHORT; | ||
| + | dir := NORTH; | ||
| + | while (dir <= MAX_EXIT) | ||
| + | { | ||
| + | if (room.exit_to[dir]) | ||
| + | buf := buf + sl.[dir] + " "; | ||
| + | dir := dir + 1; | ||
| + | } | ||
| + | return (buf); | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | Lists a room's exits as "n e u ", as the exit line in baselook.zon does (which also skips hidden ones). | ||
| − | == | + | == See also == |
| − | + | * [[Manual:DIL Manual/exit names|exit_names]] | |
| − | + | * [[Manual:DIL Manual/exit info|exit_info]] | |
| − | + | * [[Manual:DIL Manual/exit key|exit_key]] | |
| − | * | + | * [[Manual:DIL Manual/exit diff|exit_diff]] |
| − | + | * [[Manual:DIL Manual/setroomexit()|setroomexit()]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | * [[ | ||
| − | |||
| − | * [[ | ||
| − | |||
| − | |||
| − | * [[ | ||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:13, 14 November 2026
Contents
exit_to
Field (unitptr, read-only; units: rooms).
room.exit_to[dir] : unitptr
The room that the exit in direction dir leads to, or null when the room has no exit that way. dir is a direction from vme.h: NORTH (0), EAST, SOUTH, WEST, UP, DOWN, NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST (9); MAX_EXIT is the last.
Notes
- It fails when the unit is not a room (an object, a character, null) and when
diris outside 0 toMAX_EXIT. A failed value is false in anif, soif (room.exit_to[dir])is a safe test. - It can't be assigned (vmc: "Illegal lvalue"). Make or change exits with setroomexit().
- Fields can be read on the result directly:
self.outside.exit_to[dir].movementworks. - To move an NPC through an exit, use
exec("north", self)(an ordinary move, with its messages and checks) rather thanlink(self, room.exit_to[NORTH]).
Example
dilbegin string exit_list(room : unitptr);
var
dir : integer;
sl : stringlist;
buf : string;
code
{
sl := DIR_SL_SHORT;
dir := NORTH;
while (dir <= MAX_EXIT)
{
if (room.exit_to[dir])
buf := buf + sl.[dir] + " ";
dir := dir + 1;
}
return (buf);
}
dilend
Lists a room's exits as "n e u ", as the exit line in baselook.zon does (which also skips hidden ones).