Manual:DIL Manual/load()
Jump to navigation
Jump to search
load()
Function (unitptr). Makes a new NPC or object from its zone definition.
load(sym : string) : unitptr
Creates a new copy of the NPC or object defined as sym, "name@zone", and puts it inside the unit running the program: in an NPC's inventory, in an object, or in a room. Move it where it should be with link().
Parameters
| Name | Type | Meaning |
|---|---|---|
| sym | string | The symbolic name, "name@zone" (or "zone/name"). Case doesn't matter.
|
Returns
The new unit, or null when it couldn't be made: no such unit (the log says "DIL load(...) - unit does not exist."), or a room ("DIL trying to load a room ..."). A string variable that has never been given a value makes the call fail.
Notes
- The reset limits of the zone don't apply: every call makes another one.
- The new unit's DIL programs start at once, before
load()returns. - An NPC loaded by a program on an NPC or object starts inside that unit;
link()it to the room. - Rooms can't be loaded.
- A unit variable is cleared at the next
waitorpause: give or move the unit before waiting, orsecureit.
Example
dilbegin baker_gift();
var
u : unitptr;
code
{
:loop:
wait(SFB_CMD, command("bow") and (activator.type == UNIT_ST_PC));
u := load("bread@midgaard");
if (u == null)
goto loop;
act("$1n gives $3n $2n.", A_SOMEONE, self, u, activator, TO_NOTVICT);
act("$1n gives you $2n.", A_SOMEONE, self, u, activator, TO_VICT);
link(u, activator);
goto loop;
}
dilend
An NPC that hands a loaf of bread to each player who bows.