Manual:DIL Manual/subextra()

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

subextra()

Procedure. Removes an extra description by name.

subextra(list : extraptr, name : string)

Removes the first extra in the list that has name as one of its names, ignoring case. The list is a unit's field: u.extra, pc.quests or pc.info. Only one extra goes per call.

Parameters

Name Type Meaning
list extraptr The field u.extra, pc.quests or pc.info.
name string The name of the extra to remove.

Notes

  • The first argument must be the field itself. An extraptr variable is refused by vmc: "Arg 1 of 'subextra' not a unit extra description".
  • The name must be a whole name of the extra: "quest" doesn't remove an extra named "quest done".
  • When no extra matches, or the unit is null, nothing happens.
  • To remove every extra with the name, loop while name in list.
  • Don't rely on an extraptr variable that pointed at the removed extra; look the extra up again with in afterwards.

Example

dilbegin set_power(pwr : integer);
code
{
   subextra(self.extra, "$power");
   addextra(self.extra, {"$power"}, itoa(pwr));
   return;
}
dilend

Keeps one hidden $power extra on the unit, replacing the old value. Adapted from barbarian.zon.

See also