Difference between revisions of "Manual:DIL Manual/skill name()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| + | = skill name() = | ||
| + | '''Function''' (string). Gives the name of a skill from its number. | ||
| + | skill_name(i : integer) | ||
| − | < | + | The skill numbers are the <code>SKI_</code> constants in <code>vme/include/values.h</code>, for example <code>SKI_PICK_POCKETS</code> (31). The names come from the <code>name</code> lines of the skills in <code>vme/etc/commands.def</code>, in lower case: <code>skill_name(SKI_PICK_POCKETS)</code> is "pick pockets". |
| − | + | == Parameters == | |
| + | {| class="wikitable" | ||
| + | ! Name !! Type !! Meaning | ||
| + | |- | ||
| + | | i || integer || The skill number. | ||
| + | |} | ||
| − | + | == Returns == | |
| − | + | The skill's name, or "" when the number has no skill or is outside 0 to 299 (<code>SKI_TREE_MAX</code> - 1). | |
| − | |||
| − | |||
| − | + | == Notes == | |
| − | + | * The skills are numbered without gaps from 0, so a loop can go on until the name is "", as the skills list in commands.zon does. | |
| − | + | * [[Manual:DIL Manual/weapon name()|weapon name()]] does the same for weapons, but gives null, not "", outside its range. | |
| − | + | == Example == | |
| + | <pre> | ||
| + | dilbegin skill_list(pc : unitptr); | ||
| + | var | ||
| + | i : integer; | ||
| + | code | ||
| + | { | ||
| + | i := 0; | ||
| + | while (skill_name(i) != "") | ||
| + | { | ||
| + | if (pc.skills[i] > 0) | ||
| + | sendtext(itoa(pc.skills[i]) + "% " + skill_name(i) + "<br/>", pc); | ||
| + | i := i + 1; | ||
| + | } | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | Shows a player the skills they have learnt, as the skills command in commands.zon does. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/skills|skills]] | |
| − | + | * [[Manual:DIL Manual/weapon name()|weapon name()]] | |
| + | * [[Manual:DIL Manual/spellinfo()|spellinfo()]] | ||
Latest revision as of 23:08, 14 November 2026
skill name()
Function (string). Gives the name of a skill from its number.
skill_name(i : integer)
The skill numbers are the SKI_ constants in vme/include/values.h, for example SKI_PICK_POCKETS (31). The names come from the name lines of the skills in vme/etc/commands.def, in lower case: skill_name(SKI_PICK_POCKETS) is "pick pockets".
Parameters
| Name | Type | Meaning |
|---|---|---|
| i | integer | The skill number. |
Returns
The skill's name, or "" when the number has no skill or is outside 0 to 299 (SKI_TREE_MAX - 1).
Notes
- The skills are numbered without gaps from 0, so a loop can go on until the name is "", as the skills list in commands.zon does.
- weapon name() does the same for weapons, but gives null, not "", outside its range.
Example
dilbegin skill_list(pc : unitptr);
var
i : integer;
code
{
i := 0;
while (skill_name(i) != "")
{
if (pc.skills[i] > 0)
sendtext(itoa(pc.skills[i]) + "% " + skill_name(i) + "<br/>", pc);
i := i + 1;
}
}
dilend
Shows a player the skills they have learnt, as the skills command in commands.zon does.