Manual:DIL Manual/vals
Jump to navigation
Jump to search
Contents
vals
Field (intlist, read/write; on extraptr).
e.vals : intlist
The list of integers kept with an extra description. Players never see it; DIL uses it to store numbers on a unit, such as a death counter or a high-score table (competition.zon). In a zone file it is the second list in extra {"names"} {1, 2, 3} "text"; in DIL the four-argument addextra() sets it.
Notes
- Assigning an intlist replaces the list with a copy of it; assigning null empties it.
e.vals.[i]reads and assigns one element. An index outside the list fails, and an assignment to it does nothing: grow the list with insert() first, and shrink it with remove().- On a null extra it fails, and an assignment does nothing.
- Units have no
vals(vmc: "Illegal type for field"); look up an extra first:u.extra.["$name"].vals.
Example
dilbegin count_death();
var
exd : extraptr;
code
{
exd := "$TOTAL_DEATHS" in self.extra;
if (exd)
exd.vals.[0] := exd.vals.[0] + 1;
else
addextra(self.extra, {"$TOTAL_DEATHS"}, itoa(realtime), {1});
quit;
}
dilend
Counts a player's deaths in a hidden extra, as death.zon does.