1
0

function call fixes and resets for procs / call spell process

This commit is contained in:
Emagi 2024-09-02 19:14:44 -04:00
parent b7802d84db
commit 56e43288bf
2 changed files with 51 additions and 45 deletions

View File

@ -1721,6 +1721,7 @@ bool Entity::CastProc(Proc* proc, int8 type, Spawn* target) {
else {
lua_getglobal(state, "proc");
}
if (lua_isfunction(state, -1)) {
if (item_proc) {
num_args++;
lua_interface->SetItemValue(state, proc->item);
@ -1769,6 +1770,9 @@ bool Entity::CastProc(Proc* proc, int8 type, Spawn* target) {
lua_pop(state, 1);
return false;
}
}
lua_interface->ResetFunctionStack(state);
return true;
}

View File

@ -674,9 +674,11 @@ bool LuaInterface::CallSpellProcess(LuaSpell* spell, int8 num_parameters, std::s
if(lua_pcall(spell->state, num_parameters, 0, 0) != 0){
LogError("Error running function '%s' in %s: %s", customFunction.c_str(), spell->spell->GetName(), lua_tostring(spell->state, -1));
lua_pop(spell->state, 1);
ResetFunctionStack(spell->state);
RemoveSpell(spell, false); // may be in a lock
return false;
}
ResetFunctionStack(spell->state);
return true;
}