How to validate "databasenode = { }"
I've a bit of code that I need to check the value of a node.
Code:
Runtime Notice: s'manager_effect.lua' | s'adnd_processEffect' | s'nodeEffect' | databasenode = { }
When the value of nodeEffect is "{ }" I need to do something... the problem is I can't figure out a good way to test nodeEffect and that it equals { }.
The best way I could figure out was to do this.
Code:
-- check if effect still exists. removed in fCustomOnEffectActorStartTurn() probably
-- we check the .getPath() through pcall and if it fails then just end this run.
if not pcall(function () nodeEffect.getPath() end) then
Debug.console("manager_effect_adnd.lua","adnd_processEffect","nodeEffect removed in-line",nodeEffect);
return;
end
It works by running the .getPath() on the nodeEffect and if it returns an error through pcall I do what I need to do.
Is there a better way to handle this or is this the best?
The reason this happens... is during the effects processing on a players turn, they might "die" from "DMGO" effects. If that happens, in the manager_action_damage code I remove the DMGO effect (this is part of death's door for AD&D) but when it comes back here from running the custom function the effect is gone... so I test for it and continue or end this effects loop as necessary.
I could just leave the effect on the dead player and let it keep ticking and make my life easier but this does what I want (allows me to remove the effect and then apply a dead effect on them). I'm considering going that way because I had to override a bit of CoreRPG code to do this...