WoW:API GetSkillLineInfo: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(→‎Example: Cleaned up example code slightly to be a bit more optimized.)
Line 33: Line 33:
== Example ==
== Example ==
  for skillIndex = 1, GetNumSkillLines() do
  for skillIndex = 1, GetNumSkillLines() do
   skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
   local skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
     skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
     skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
     skillDescription = GetSkillLineInfo(skillIndex)
     skillDescription = GetSkillLineInfo(skillIndex)
   if isHeader == nil then
   if not isHeader then
       DEFAULT_CHAT_FRAME:AddMessage("Skill: " .. skillName .. " - " .. skillRank)
       print(string.format("Skill: %s - %s", skillName, skillRank))
   end
   end
  end
  end
Line 48: Line 48:
  Leatherworking - 300
  Leatherworking - 300


[[Category:World of Warcraft API]]


====Another Example====
====Another Example====
Line 63: Line 62:


:For more information on this method try the Lua website:[http://www.lua.org/pil/5.1.html]
:For more information on this method try the Lua website:[http://www.lua.org/pil/5.1.html]
[[Category:World of Warcraft API]]

Revision as of 23:19, 25 September 2009

WoW API < GetSkillLineInfo


Returns the name and other information which is associated with the specific skill or skill header in the game.

skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
  skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
  skillDescription = GetSkillLineInfo(skillIndex)

Parameters

Arguments

(skillIndex)
skillIndex
Integer - The row of the skill display to request information from.

Returns

skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier, skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType, skillDescription
skillName
String - The name of the skill/header
isHeader
Flag - 1 if row is header, nil otherwise.
isExpanded
Flag - 1 if row is expanded, nil otherwise.
skillRank
Integer - The current rank for the current skill
numTempPoints
Integer - Temporary points for the current skill
skillModifier
Integer - Skill modifier value for the current skill
skillMaxRank
Integer - The maximum rank for the current skill
isAbandonable
Flag - 1 if skill can be unlearned, nil otherwise.
stepCost
Flag - 1 if skill can be learned, nil otherwise.
rankCost
Flag - 1 if skill can be trained, nil otherwise.
minLevel
Integer - Minimum level required to learn this skill
skillCostType
Integer - Unknown, seems to be related to primary and secondary skills
skillDescription
String - Skill Description Text, localised


Example

for skillIndex = 1, GetNumSkillLines() do
  local skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier,
    skillMaxRank, isAbandonable, stepCost, rankCost, minLevel, skillCostType,
    skillDescription = GetSkillLineInfo(skillIndex)
  if not isHeader then
     print(string.format("Skill: %s - %s", skillName, skillRank))
  end
end

Result

Prints each skills's name and rank.
Two-Handed Mace - 229
Cooking - 278
Staves - 150
Leatherworking - 300


Another Example

Lets say you only want a specific return value, and you do not want to waste a lot of variables or characters to get it. What you can do is assign all the returns values to an array, and then select the element of the array that corresponds with the return value you want. For example if you wanted only the skillRank of riding(if you have all the secondary skills) you can use the following code:
/script array = {GetSkillLineInfo(12)}
/script DEFAULT_CHAT_FRAME:AddMessage(array[4])

Where:

  • 12 is the skillIndex of Riding.
  • 4 is the index of the skillRank in the array


For more information on this method try the Lua website:[1]