-
Posted by i2ichardt on Mon, 10 Jan 2011 15:27:40
I want to make a string taken from the target mobs name and convert it to be a table name instead of just a string.
Bloodtalon_ScythemawSpells = {}; --Defines Table Bloodtalon_ScythemawSpells[1] = "16827"; -- Claw Bloodtalon_ScythemawSpells[2] = "2649"; -- Growl Bloodtalon_ScythemawSpells[3] = "13443"; -- Rend Bloodtalon_ScythemawSpells[4] = "6268"; -- Rushing Charge local tar = UnitName("target"); local TempFName, TempLName = strsplit(" ",tostring(tar)); local TableName = (TempFName.."_"..TempLName.."Spells"); print(#TableName); --Return the number of spells in the table
Currently TableName in the last print line is a string, i want it to reference the table defined on the first line. I can't figure it out.
-
Posted by jnwhiteh on Mon, 10 Jan 2011 15:51:59
I want to make a string taken from the target mobs name and convert it to be a table name instead of just a string.
Bloodtalon_ScythemawSpells = {}; --Defines Table Bloodtalon_ScythemawSpells[1] = "16827"; -- Claw Bloodtalon_ScythemawSpells[2] = "2649"; -- Growl Bloodtalon_ScythemawSpells[3] = "13443"; -- Rend Bloodtalon_ScythemawSpells[4] = "6268"; -- Rushing Charge local tar = UnitName("target"); local TempFName, TempLName = strsplit(" ",tostring(tar)); local TableName = (TempFName.."_"..TempLName.."Spells"); print(#TableName); --Return the number of spells in the table
Currently TableName in the last print line is a string, i want it to reference the table defined on the first line. I can't figure it out.
This is because these lines:
local TempFName, TempLName = strsplit(" ",tostring(tar)); local TableName = (TempFName.."_"..TempLName.."Spells");
Just creates a string. You can't just turn a string into a table, but you can use a lookup table to do this.
local MobInfo = {} MobInfo["Bloodtalon Scythemaw"] = {} MobInfo["Bloodtalon Scythemaw"][1] = "16827"; -- Claw
Then you can just do:
MobInfo[tar]
to get at that info table. -
Posted by i2ichardt on Tue, 11 Jan 2011 06:41:27
Thank You.
Had to change it a lil to get it to work though:
print(#MobDatabase[tar]);