bizao030188
Member
- Joined
- Jun 4, 2012
- Messages
- 50
- Solutions
- 2
- Reaction score
- 7
Hello friends!
I am working in a system that needs to get the name of the attacks from monster xml.
I found out in luascript.cpp the correspondent function but it does not have the option to return the name:
so I want to add a new field setField(L, "name", spellBlock.name); but I got some errors saying that struct spellBlock has no member called "name" . So the question is, where else should I insert the "name" field?
Thanks in advance!
I am working in a system that needs to get the name of the attacks from monster xml.
I found out in luascript.cpp the correspondent function but it does not have the option to return the name:
C++:
int LuaScriptInterface::luaMonsterTypeGetAttackList(lua_State* L)
{
// monsterType:getAttackList()
MonsterType* monsterType = getUserdata<MonsterType>(L, 1);
if (!monsterType) {
lua_pushnil(L);
return 1;
}
lua_createtable(L, monsterType->info.attackSpells.size(), 0);
int index = 0;
for (const auto& spellBlock : monsterType->info.attackSpells) {
lua_createtable(L, 0, 8);
setField(L, "chance", spellBlock.chance);
setField(L, "isCombatSpell", spellBlock.combatSpell ? 1 : 0);
setField(L, "isMelee", spellBlock.isMelee ? 1 : 0);
setField(L, "minCombatValue", spellBlock.minCombatValue);
setField(L, "maxCombatValue", spellBlock.maxCombatValue);
setField(L, "range", spellBlock.range);
setField(L, "speed", spellBlock.speed);
pushUserdata<CombatSpell>(L, static_cast<CombatSpell*>(spellBlock.spell));
lua_setfield(L, -2, "spell");
lua_rawseti(L, -2, ++index);
}
return 1;
}
so I want to add a new field setField(L, "name", spellBlock.name); but I got some errors saying that struct spellBlock has no member called "name" . So the question is, where else should I insert the "name" field?
Thanks in advance!
Last edited: