Manual:DIL Manual/addextra()
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
inandu.extra.["name"]. To replace an extra,subextra()it first. - On a field of a null unit, or
pc.questsorpc.infoon something that isn't a player, nothing happens. {...}takes only constants. Names that come from variables go in a stringlist built withaddstring().- For quests, use the functions in quests.zon (
qstSetOngoing@questsand the others) rather than writing the extras by hand, so every quest looks the same in thequestscommand.
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.