Pazyryk
Deity
- Joined
- Jun 13, 2008
- Messages
- 3,584
Does the pUnit object hang around somewhere after the unit is dead?
One thing I'd like to be able to do is recover information from a unit after it is dead, regardless of how it was killed (i.e., by combat, disbanding, sinking with a ship as cargo, or any other means I haven't thought of). If I store a Lua reference to pUnit and the unit is subsequently eliminated:
I thought that running a method on a non-existent pUnit would throw and error or maybe even CTD. But if that's the case, how in the world could pUnit:IsDead() ever have a true value? (And it is used by base files according to Wiki.)
One thing I'd like to be able to do is recover information from a unit after it is dead, regardless of how it was killed (i.e., by combat, disbanding, sinking with a ship as cargo, or any other means I haven't thought of). If I store a Lua reference to pUnit and the unit is subsequently eliminated:
- would pUnit:IsDead() = true? Or am I likely to get an error or CTD for running a method on a non-existent object?
- if yes above, for how long? (only this turn? 100 turns later? certainly not after exit/reload because these objects are really just Lua tables that would be reassigned if they still exist at all)
- would pUnit:GetID() still give me the old unitID?
- would pUnit:GetScriptData() still hold the string I assigned before the unit was eliminated?
I thought that running a method on a non-existent pUnit would throw and error or maybe even CTD. But if that's the case, how in the world could pUnit:IsDead() ever have a true value? (And it is used by base files according to Wiki.)