Difference between revisions of "Manual:DIL Manual/UNIT ST ROOM"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="uroom"></span>
+
= UNIT_ST_ROOM =
−
'''if the type is UNIT_ST_ROOM'''
+
'''Constant''' (integer, vme.h: 0x04).
  
−
      Note: the descr fields of exits are available as standard extra
+
A room. <code>u.type == UNIT_ST_ROOM</code>. The type of a unit is in its <code>type</code> field; the four unit types are bits, so they can be combined with <code>|</code>.
−
          keywords, ie. 'north' ,'east',...,'down'.
 
−
          Example:
 
−
            ex := 'north' in self.extra;
 
  
−
      'exit_names'[]  :stringlist (RW)
+
== Fields ==
−
          The names matching the exit name 'open grate' The index should
+
Only rooms have: [[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/exit to|exit_to]], [[Manual:DIL Manual/roomflags|roomflags]], [[Manual:DIL Manual/movement|movement]], [[Manual:DIL Manual/mapx|mapx]], [[Manual:DIL Manual/mapy|mapy]]. The exit fields take a direction as index, from <code>NORTH</code> (0) to <code>MAX_EXIT</code> (9) (vme.h).
−
          be one of NORTH EAST SOUTH WEST UP DOWN in values.h and/or vme.h
 
−
          Example:
 
−
            sl := self.exit_names[SOUTH];
 
−
            act("The $2t slides open as you press the button.",
 
−
                A_ALWAYS, activator, sl.[0], null, TO_CHAR);
 
−
      'exit_info'[] :integer (RW)
 
−
          Bits specifying the conditions of the exits, see EX_* in
 
−
          values.h and/or vme.h The index should be one of NORTH EAST SOUTH WEST
 
−
          UP DOWN in values.h and/or vme.h
 
−
      'exit_to'[]    :unitptr (RO)
 
−
          The unit, the direction exits to. The index should
 
−
          be one of NORTH EAST SOUTH WEST UP DOWN in values.h and/or vme.h
 
−
          You may not change the directions through DIL programs.
 
−
      'roomflags'    :integer (RW)
 
−
          Bits specifying properties of the room, see ROOM_FL_* in
 
−
          values.h and/or vme.h
 
−
      'movement'    :integer (RW)
 
−
          The type of movement in the room, see SECT_* in values.h and/or vme.h
 
−
<span id="uroom"></span>
 
−
'''if the type is UNIT_ST_ROOM'''
 
  
−
      Note: the descr fields of exits are available as standard extra
+
== Notes ==
−
          keywords, ie. 'north' ,'east',...,'down'.
+
* Every unit, whatever its type, has the general fields: [[Manual:DIL Manual/name|name]], [[Manual:DIL Manual/names|names]], [[Manual:DIL Manual/title|title]], [[Manual:DIL Manual/descr|descr]], [[Manual:DIL Manual/outside descr|outside_descr]], [[Manual:DIL Manual/inside descr|inside_descr]], [[Manual:DIL Manual/extra|extra]], [[Manual:DIL Manual/type|type]], [[Manual:DIL Manual/symname|symname]], [[Manual:DIL Manual/nameidx|nameidx]], [[Manual:DIL Manual/zoneidx|zoneidx]], [[Manual:DIL Manual/zone|zone]], [[Manual:DIL Manual/key|key]], [[Manual:DIL Manual/outside|outside]], [[Manual:DIL Manual/inside|inside]], [[Manual:DIL Manual/next|next]], [[Manual:DIL Manual/gnext|gnext]], [[Manual:DIL Manual/gprevious|gprevious]], [[Manual:DIL Manual/flags|flags]], [[Manual:DIL Manual/manipulate|manipulate]], [[Manual:DIL Manual/openflags|openflags]], [[Manual:DIL Manual/opendiff|opendiff]], [[Manual:DIL Manual/weight|weight]], [[Manual:DIL Manual/baseweight|baseweight]], [[Manual:DIL Manual/capacity|capacity]], [[Manual:DIL Manual/height|height]], [[Manual:DIL Manual/light|light]], [[Manual:DIL Manual/bright|bright]], [[Manual:DIL Manual/illum|illum]], [[Manual:DIL Manual/minv|minv]], [[Manual:DIL Manual/alignment|alignment]], [[Manual:DIL Manual/hp|hp]], [[Manual:DIL Manual/max hp|max_hp]], [[Manual:DIL Manual/loadcount|loadcount]], [[Manual:DIL Manual/hasfunc|hasfunc]], [[Manual:DIL Manual/spells|spells]].
−
          Example:
+
* <code>spells[]</code> on a room is its magic resistance; the index is not used.
−
            ex := 'north' in self.extra;
+
* A room can be inside another room. <code>self.outside</code> of a room is the room around it, or null.
 +
* Reading a field the unit doesn't have fails, and a failed value is false in every comparison: test the type first.
  
−
      'exit_names'[]  :stringlist (RW)
+
== Example ==
−
          The names matching the exit name 'open grate' The index should
+
<pre>
−
          be one of NORTH EAST SOUTH WEST UP DOWN in values.h and/or vme.h
+
dilbegin integer exits(room : unitptr);
−
          Example:
+
var
−
            sl := self.exit_names[SOUTH];
+
  i : integer;
−
            act("The $2t slides open as you press the button.",
+
  n : integer;
−
                A_ALWAYS, activator, sl.[0], null, TO_CHAR);
+
code
−
      'exit_info'[]  :integer (RW)
+
{
−
          Bits specifying the conditions of the exits, see EX_* in
+
  if (room.type != UNIT_ST_ROOM)
−
          values.h and/or vme.h The index should be one of NORTH EAST SOUTH WEST
+
      return (0);
−
          UP DOWN in values.h and/or vme.h
+
  i := 0;
−
      'exit_to'[]    :unitptr (RO)
+
  n := 0;
−
          The unit, the direction exits to. The index should
+
  while (i <= MAX_EXIT)
−
          be one of NORTH EAST SOUTH WEST UP DOWN in values.h and/or vme.h
+
  {
−
          You may not change the directions through DIL programs.
+
      if (room.exit_to[i] != null)
−
      'roomflags'    :integer (RW)
+
        n := n + 1;
−
          Bits specifying properties of the room, see ROOM_FL_* in
+
      i := i + 1;
−
          values.h and/or vme.h
+
  }
−
      'movement'    :integer (RW)
+
  return (n);
−
          The type of movement in the room, see SECT_* in values.h and/or vme.h
+
}
 +
dilend
 +
</pre>
 +
Counts a room's exits.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/type|type]]
 +
* [[Manual:DIL Manual/Fields|Fields]]
 +
* [[Manual:DIL Manual/UNIT ST PC|UNIT_ST_PC]]
 +
* [[Manual:DIL Manual/UNIT ST NPC|UNIT_ST_NPC]]
 +
* [[Manual:DIL Manual/UNIT ST PC and UNIT ST NPC|UNIT_ST_PC and UNIT_ST_NPC]]
 +
* [[Manual:DIL Manual/UNIT ST OBJ|UNIT_ST_OBJ]]

Latest revision as of 23:24, 14 November 2026

UNIT_ST_ROOM

Constant (integer, vme.h: 0x04).

A room. u.type == UNIT_ST_ROOM. The type of a unit is in its type field; the four unit types are bits, so they can be combined with |.

Fields

Only rooms have: exit_names, exit_info, exit_key, exit_diff, exit_to, roomflags, movement, mapx, mapy. The exit fields take a direction as index, from NORTH (0) to MAX_EXIT (9) (vme.h).

Notes

Example

dilbegin integer exits(room : unitptr);
var
   i : integer;
   n : integer;
code
{
   if (room.type != UNIT_ST_ROOM)
      return (0);
   i := 0;
   n := 0;
   while (i <= MAX_EXIT)
   {
      if (room.exit_to[i] != null)
         n := n + 1;
      i := i + 1;
   }
   return (n);
}
dilend

Counts a room's exits.

See also