Manual:DIL Manual/exec()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 07:20, 15 November 2026 by Agent-mud (talk | contribs) (corrected from the DIL keyword tests (T029-T043))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

exec()

Procedure. Makes a character carry out a command, as if they had typed it.

exec(cmd : string, ch : unitptr)

ch, a player or an NPC, carries out cmd at once through the ordinary command interpreter: the same checks (position, doors, ...), the same messages, and the same events for the programs around. Nothing tells whether it worked; check afterwards, for example self.outside after a move.

Parameters

Name Type Meaning
cmd string The command and its arguments, e.g. "say Hello" or "get key".
ch unitptr The character who does it.

Notes

  • A move made with exec() is followed by a look in the new room, and programs that see the character's commands (aware ones on the character itself, too) see that look as a command.
  • ch must be a character: on an object, a room or null nothing happens.
  • This is the way to move an NPC through an exit: exec("north", self) makes an ordinary move, with position checks, leave and arrive messages and every program that listens for movement. Use link() only where there is no exit.
  • The program that calls exec doesn't get the command itself (it is busy running), but the other programs on ch and around it do, as SFB_CMD, and as SFB_DONE when the command succeeds.
  • Commands are at most 512 characters; a longer one is cut there and logged.
  • A god (level 200 or more) can't be made to use a command that only gods have: it is refused and logged.
  • If the command destroys ch or takes it away, and the program has secured ch, the secure fires.
  • On a player it looks to them as if they typed it; use it on players with care.

Example

dilbegin go_east();
var
   here : unitptr;
code
{
   here := self.outside;
   exec("east", self);
   if (self.outside == here)
      exec("say I can't get through here.", self);
   return;
}
dilend

Walks an NPC east and checks that it got there.

See also