Page 1 of 1
LuaSpell from Spell
Posted: Wed Aug 17, 2016 6:41 pm
by Gangrenous
This is about as clear as mud to me. I understand why there is LuaSpell compared to Spell, I get that part. They are two completely different things, but related. So if I create a LuaSpell object in C++, how can I get the object from it's Spell counterpart, make sense?
I do not think I can do a direct cast, I think I have tried.
Re: LuaSpell from Spell
Posted: Wed Aug 17, 2016 7:12 pm
by Jabantiz
LuaSpell contains a pointer to Spell simply called spell
Code: Select all
LuaSpell* spell;
spell->spell->(What ever you need from Spell*)
EDIT: And I got that backwards, you want LuaSpell from a Spell, not sure that is possible will need to check.
EDIT2: Ok it looks like this is the best way to get the LuaSpell* from a spell
Code: Select all
string lua_script = spell->GetSpellData()->lua_script;
lua_script.append(".lua");
lua_spell = 0;
if(lua_interface)
lua_spell = lua_interface->GetSpell(lua_script.c_str());
However this returns a copy of the LuaSpell and not the original and needs to be deleted when finished, if you just need info from the LuaSpell it will work find, if you need to modify the LuaSpell this will not work.
Re: LuaSpell from Spell
Posted: Wed Aug 17, 2016 8:47 pm
by Gangrenous
I started writing my own routines a few hours after, I have it working. I just need to clean up the code some but it is working.