Difference between revisions of "Manual:DIL Manual/skill name()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bfskill_name"></span>
+
= skill name() =
 +
'''Function''' (string). Gives the name of a skill from its number.
  
−
  '''Function:'''  <i><!--CODE-->string skill_name( i : integer ) ;</i><!--ENDCODE-->
+
  skill_name(i : integer)
  
−
<!--TERM--> '''i'''
+
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".
−
<!--DEFINITION-->         Skill to get the name of ass defined in 'values.h' and 'commands.def'
 
−
<!--TERM--> '''returns'''
 
−
<!--DEFINITION-->         The name of the skill that corresponds with the integer value
 
  
−
'''example:'''
+
== Parameters ==
−
<i><!--CODE-->
+
{| class="wikitable"
−
---~---~---~---~---~---~---~---~---
+
! Name !! Type !! Meaning
 +
|-
 +
| i || integer || The skill number.
 +
|}
  
−
myski:=skill_name(5);
+
== 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.
  
−
</i><!--ENDCODE-->
+
== Example ==
−
<span id="bfskill_name"></span>
+
<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.
  
−
'''Function:'''  <i><!--CODE-->string skill_name( i : integer ) ;</i><!--ENDCODE-->
+
== See also ==
−
 
+
* [[Manual:DIL Manual/skills|skills]]
−
<!--TERM-->  '''i'''
+
* [[Manual:DIL Manual/weapon name()|weapon name()]]
−
<!--DEFINITION-->        Skill to get the name of ass defined in 'values.h' and 'commands.def'
+
* [[Manual:DIL Manual/spellinfo()|spellinfo()]]
−
<!--TERM-->  '''returns'''
 
−
<!--DEFINITION-->        The name of the skill that corresponds with the integer value
 
−
 
 
−
'''example:'''
 
−
<i><!--CODE-->
 
−
---~---~---~---~---~---~---~---~---
 
−
 
 
−
myski:=skill_name(5);
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 
−
 
 
−
</i><!--ENDCODE-->
 

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.

See also