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
entry.entity and entry.entity.valid ?
entry.entity and entry.entity.valid ?
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance
-
- Filter Inserter
- Posts: 587
- Joined: Sun Jun 09, 2019 10:40 pm
- Contact:
Re: entry.entity and entry.entity.valid ?
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.
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.