Manual:DIL Manual/addextra()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:23, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

addextra()

Procedure. Adds an extra description to a unit's extras, quests or info.

addextra(list : extraptr, names : stringlist, text : string)
addextra(list : extraptr, names : stringlist, text : string, vals : intlist)

Makes a new extra description with the given names and text (and numbers, in the second form) and puts it first in the list. The list is a unit's field: u.extra on any unit, or pc.quests and pc.info on a player. Scripts often keep data in hidden extras whose names start with $, and a quest marks a player with an extra in pc.quests.

Parameters

Name Type Meaning
list extraptr The field u.extra, pc.quests or pc.info.
names stringlist The names of the new extra (its .names); may be null for none.
text string Its text (.descr). "" is fine.
vals intlist Optional: numbers for its .vals.

Notes

  • The first argument must be the field itself. An extraptr variable is refused by vmc: "Arg 1 of 'addextra' not a unit extra description".
  • An extra with the same name already there stays: the new one comes first and hides it from in and u.extra.["name"]. To replace an extra, subextra() it first.
  • On a field of a null unit, or pc.quests or pc.info on something that isn't a player, nothing happens.
  • {...} takes only constants. Names that come from variables go in a stringlist built with addstring().
  • For quests, use the functions in quests.zon (qstSetOngoing@quests and the others) rather than writing the extras by hand, so every quest looks the same in the quests command.

Example

dilbegin quest_finish(pc : unitptr, qon : string, qdone : string);
var
   sl : stringlist;
code
{
   subextra(pc.quests, qon);
   sl := null;
   addstring(sl, qdone);
   addextra(pc.quests, sl, "");
   return;
}
dilend

Swaps a player's "ongoing" quest entry for a "complete" one. Adapted from quests.zon.

See also