Quantcast
GetSpellPowerCost Returning nil - WoWInterface
Thread Tools Display Modes
07-14-22, 03:07 PM   #1
d1ce
A Kobold Labourer
Join Date: Jul 2022
Posts: 1
GetSpellPowerCost Returning nil

Hi

I am trying to retrieve the cost from the function GetSpellPowerCost within Classic TBC, but it seems no matter how I run it, the result is nil.

The following code returns nil:

Lua Code:
  1. spellInfo = GetSpellPowerCost(133)[cost]
  2. print(spellInfo)

As does:

Lua Code:
  1. spellInfo = GetSpellPowerCost(133)
  2. print(spellInfo[cost])

And:

Lua Code:
  1. spellInfo = GetSpellPowerCost(133)
  2. spellCost = spellInfo[cost]
  3. print(spellInfo)

Which are admittedly trying the same thing.

The only way I can get the info to show up is if I run the following in-game:

/dump GetSpellPowerCost(133)

But then that provides me with the whole table information, not the specific key/value set that I am looking for.

I am relatively new to Lua scripting, especially within WoW, so any guidance is appreciated. Thanks!

**EDIT** I am an idiot- it should be

Lua Code:
  1. spellInfo = GetSpellPowerCost(133)[1].cost
  2. print(spellInfo)

Last edited by d1ce : 07-14-22 at 04:07 PM. Reason: Solved
  Reply With Quote
07-14-22, 04:12 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,540
If you want to see the whole table (and the local is important so you don't screw up other addons or the game UI).
Lua Code:
  1. local spellInfo = GetSpellPowerCost(133)
  2. for k, v in pairs(spellInfo) do
  3.     print(v.name, v.cost)
  4. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetSpellPowerCost Returning nil

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off