WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   GetSpellPowerCost Returning nil (https://www.wowinterface.com/forums/showthread.php?t=59170)

d1ce 07-14-22 03:07 PM

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)

Fizzlemizz 07-14-22 04:12 PM

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


All times are GMT -6. The time now is 01:49 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI