Manual:DIL Manual/link()
Jump to navigation
Jump to search
link()
Procedure. Moves a unit into another unit, with no checks and no messages.
link(u : unitptr, into : unitptr)
link puts u inside into: a character into a room, an object into a container or into a character's inventory, and so on. It is a plain move: there are no messages, and no checks of position, doors, exits, weight or capacity. Give the messages yourself with act().
To move an NPC through an exit, use exec("north", self) instead, so that it is an ordinary move, then check self.outside. Use link where there is no exit (teleports, magic, a ship moving between rooms).
Parameters
| Name | Type | Meaning |
|---|---|---|
| u | unitptr | The unit to move. |
| into | unitptr | Where to put it. |
Notes
- Nothing happens when either is null, when
intoisuitself or is insideu, or whenuis a room andintoisn't.findroom()returns null for a room that doesn't exist, solink(pc, findroom(...))does nothing then. - An object that is worn or wielded is taken off first.
- Programs that wait for someone to walk in or out don't hear about it, and a player moved into a room doesn't see it until they look:
exec("look", pc). - When the program has
secureduand moves it out of its surroundings, the secure fires at the next wake. - In a
whileloop overu.next, the next unit afterlinkis in the other place. Useforeach()for a loop that moves units.
Example
dilbegin send_home(pc : unitptr);
var
home : unitptr;
code
{
home := findroom(pc.hometown);
if (home == null)
return;
act("$1n vanishes in a flash of light!", A_HIDEINV, pc, null, null, TO_ROOM);
link(pc, home);
act("$1n materializes.", A_HIDEINV, pc, null, null, TO_ROOM);
exec("look", pc);
return;
}
dilend
Sends a player to their home town, with messages in both rooms. Adapted from basis.zon.