If you set a tree's health to 0 to make it indestructible and can not be attacked, it will slowly regenerate health from 0.
0 would seem to have a special significance given it impacts biters and its not a reachable state in normal scenarios without the tree dieing. So I don't believe health should be regenerated from it, as it takes the tree out of this special can't be attacked state.
https://lua-api.factorio.com/latest/Lua ... ity.health
This was originally posted as a bug as I believe it to be, but Rseding believes it is working as "intended" and is therefore a request to change "intended".
viewtopic.php?p=530064
Trees shouldn't regenerate health from 0
- Muppet9010
- Filter Inserter
- Posts: 281
- Joined: Sat Dec 09, 2017 6:01 pm
- Contact:
Re: Trees shouldn't regenerate health from 0
0 healh is not special invincibility state, entities just can't be attacked when they have 0 health due to implementation details of targeting and damage dealing systems, so the behavior is documented, as some people expected setting health to 0 to kill the entity. I consider setting health to 0 to make an entity invincible to be a hack.
Re: Trees shouldn't regenerate health from 0
As Posila said: there's nothing special about 0 health. Simply: to attack an entity you must be able to damage it. To damage an entity it must have a positive health value after subtracting all existing damage-to-be-taken. In the case of 0 health; 0 is not positive so an entity with 0 health doesn't satisfy those requirements and can't be attacked.
If you want to set an entity with health to be indestructible there's an explicit flag to do that: https://lua-api.factorio.com/latest/Lua ... structible
If you want to set an entity with health to be indestructible there's an explicit flag to do that: https://lua-api.factorio.com/latest/Lua ... structible
If you want to get ahold of me I'm almost always on Discord.
Re: Trees shouldn't regenerate health from 0
Why not just set the tree `destructible = false` to make it indestructible?Muppet9010 wrote: Sun Jan 03, 2021 6:23 pm If you set a tree's health to 0 to make it indestructible
https://lua-api.factorio.com/latest/Lua ... structible
Re: Trees shouldn't regenerate health from 0
Since the kill check is only performed during a successful attack, would it make sense to add the kill check to the LuaEntity.health setter? Thus eliminating the hack.
- Muppet9010
- Filter Inserter
- Posts: 281
- Joined: Sat Dec 09, 2017 6:01 pm
- Contact:
Re: Trees shouldn't regenerate health from 0
This arose as a work around for this other bug: viewtopic.php?f=7&t=93880
Basically I have a modded mine that makes everything in its radius inactive and indestructible. But other biters that were trying to path through these would often start attacking trees or player force entities, despite them being indestructible.
Mod concept:

https://mods.factorio.com/mod/stasis_mine
When I looked around I found the references to health of 0 made things unattackable and this fixed my issue. On reading the API docs I believed it was saying health of 0 was special. A 0 health entity had no health bar shown, but I saw trees would regain health and thus show a health bar of near 0 after a few seconds. Hence this bug/suggestion around tree health.
So sounds like I have taken a rather confused walk and ended up somewhere odd.
Basically I have a modded mine that makes everything in its radius inactive and indestructible. But other biters that were trying to path through these would often start attacking trees or player force entities, despite them being indestructible.
Mod concept:

https://mods.factorio.com/mod/stasis_mine
When I looked around I found the references to health of 0 made things unattackable and this fixed my issue. On reading the API docs I believed it was saying health of 0 was special. A 0 health entity had no health bar shown, but I saw trees would regain health and thus show a health bar of near 0 after a few seconds. Hence this bug/suggestion around tree health.
So sounds like I have taken a rather confused walk and ended up somewhere odd.