LuaSpell from Spell

General support forum. If you require assistance and your problem doesnt fall in any of the other categories, this is the forum for you!

Moderator: Team Members

Forum rules
READ THE FORUM STICKY THREADS BEFORE ASKING FOR HELP!
Most information can be found there, and if not, the posts will help you determine the information required to get assistance from the development team.
Incomplete Help Requests will be locked or deleted.
Post Reply
User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

LuaSpell from Spell

Post by Gangrenous » Wed Aug 17, 2016 6:41 pm

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.
Resident Dirty Hippy

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: LuaSpell from Spell

Post by Jabantiz » Wed Aug 17, 2016 7:12 pm

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.

User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Re: LuaSpell from Spell

Post by Gangrenous » Wed Aug 17, 2016 8:47 pm

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.
Resident Dirty Hippy

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests