Manual:DIL Manual/string in extraptr
Jump to navigation
Jump to search
string in extraptr
Operator (extraptr).
s in exlist : extraptr
Finds the extra description whose names include s, in a list of extras such as u.extra or pc.quests, and gives that extra; null when there is none. Use it to find hidden data extras ("$visits" in pc.extra) and quest entries.
Returns
The first extra in the list with a name equal to s, or null. Read its descr, names and vals fields, or change them.
Notes
- The name must match exactly, letter by letter; only case is ignored.
"$visit" in u.extradoesn't find an extra named "$visits", and no partial words or first words match, unlikeinwith a stringlist. - Spaces before
sare skipped; spaces after it are not. - An extra with no names at all is found by
"". u.extra.["$visits"]does the same search.- The extraptr is only good until the program waits: after
wait()orpauseevery extraptr variable is null, so look it up again.
Example
dilbegin integer visits(pc : unitptr);
var
exd : extraptr;
code
{
exd := "$visits" in pc.extra;
if (exd == null)
{
addextra(pc.extra, {"$visits"}, "1");
return (1);
}
exd.descr := itoa(atoi(exd.descr) + 1);
return (atoi(exd.descr));
}
dilend
Counts a player's visits in a hidden extra and gives the new count.