• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Get spell group

Frikx

Computer Science
Joined
Mar 10, 2013
Messages
128
Solutions
3
Reaction score
31
Location
Spain
GitHub
amatria
Hey yo!!

I'm actually working on a script to sort spells and I really need to access to the spell group (Attack, healing, etc) :

XML:
<instant group="healing" spellid="144" name="Cure Bleeding" words="exana kor" lvl="45" mana="30" prem="1" aggressive="0" selftarget="1" cooldown="6000" groupcooldown="1000" needlearn="0" script="healing/cure_bleeding.lua">
   <vocation name="Druid" />
   <vocation name="Knight" />
   <vocation name="Elder Druid" />
   <vocation name="Elite Knight" />
</instant>

I've checked the spell metatable and it has confirmed the worst of my theories...

C++:
void LuaScriptInterface::pushInstantSpell(lua_State* L, const InstantSpell& spell)
{
    lua_createtable(L, 0, 6);

    setField(L, "name", spell.getName());
    setField(L, "words", spell.getWords());
    setField(L, "level", spell.getLevel());
    setField(L, "mlevel", spell.getMagicLevel());
    setField(L, "mana", spell.getMana());
    setField(L, "manapercent", spell.getManaPercent());

    setMetatable(L, -1, "Spell");
}

Any idea?
 
Solution
Hey yo!!

I'm actually working on a script to sort spells and I really need to access to the spell group (Attack, healing, etc) :

XML:
<instant group="healing" spellid="144" name="Cure Bleeding" words="exana kor" lvl="45" mana="30" prem="1" aggressive="0" selftarget="1" cooldown="6000" groupcooldown="1000" needlearn="0" script="healing/cure_bleeding.lua">
   <vocation name="Druid" />
   <vocation name="Knight" />
   <vocation name="Elder Druid" />
   <vocation name="Elite Knight" />
</instant>

I've checked the spell metatable and it has confirmed the worst of my theories...

C++:
void LuaScriptInterface::pushInstantSpell(lua_State* L, const InstantSpell& spell)
{
    lua_createtable(L, 0, 6);

    setField(L, "name"...
Add new function to spell class in spells.h, which returns group of spell, you will find group variable in this class under protected, then just add entry to lua function.
 
Hey yo!!

I'm actually working on a script to sort spells and I really need to access to the spell group (Attack, healing, etc) :

XML:
<instant group="healing" spellid="144" name="Cure Bleeding" words="exana kor" lvl="45" mana="30" prem="1" aggressive="0" selftarget="1" cooldown="6000" groupcooldown="1000" needlearn="0" script="healing/cure_bleeding.lua">
   <vocation name="Druid" />
   <vocation name="Knight" />
   <vocation name="Elder Druid" />
   <vocation name="Elite Knight" />
</instant>

I've checked the spell metatable and it has confirmed the worst of my theories...

C++:
void LuaScriptInterface::pushInstantSpell(lua_State* L, const InstantSpell& spell)
{
    lua_createtable(L, 0, 6);

    setField(L, "name", spell.getName());
    setField(L, "words", spell.getWords());
    setField(L, "level", spell.getLevel());
    setField(L, "mlevel", spell.getMagicLevel());
    setField(L, "mana", spell.getMana());
    setField(L, "manapercent", spell.getManaPercent());

    setMetatable(L, -1, "Spell");
}

Any idea?
Use this script it will generate a table of all the spells in your spells.xml so you can reference whatever attributes you need to for your script, no need to edit the source.
Spells Parser - Configurable - Any TFS / OTX Version
 
Solution
Use this script it will generate a table of all the spells in your spells.xml so you can reference whatever attributes you need to for your script, no need to edit the source.
Spells Parser - Configurable - Any TFS / OTX Version
Good code, but for such a small change that the author want, I believe source edit is better thing to do if everything else is already done and ready to use.
 
Back
Top