Page 1 of 1

entry.entity and entry.entity.valid ?

Posted: Thu Jul 25, 2019 6:46 pm
by ownlyme
i know that in events, you should use both.
But is there any case where you need both safety checks for a reference you stored in a variable?
For example when the entity/gui/etc gets removed upon mod uninstallation?

when i destroy an entity, its reference usually (always?) remains in the variable, it'll just be invalid

Re: entry.entity and entry.entity.valid ?

Posted: Fri Jul 26, 2019 9:00 pm
by slippycheeze
If you are holding the entity with as strong reference, in a private table or variable, then it will not become nil magically, no.

The whole valid thing exists literally because of that fact, so yeah, you can omit the nil check if you want. The extra nil check is, like, absolutely free, but if you feel strongly, skip it.