A way to change Stats for Units in game?
-
- Manual Inserter
- Posts: 4
- Joined: Tue Jan 17, 2017 1:18 am
- Contact:
A way to change Stats for Units in game?
How to change the max_health of a turret with many kills, for example?
Re: A way to change Stats for Units in game?
There's no way to change the max health of an entity runtime.
If the max health could be changed runtime that means we would need to save the max health in the save file for every entity that has health and that would increase the save size for something that would virtually never be used but is on a *lot* of entities. All trees + all player buildings + all biters/nests.
If the max health could be changed runtime that means we would need to save the max health in the save file for every entity that has health and that would increase the save size for something that would virtually never be used but is on a *lot* of entities. All trees + all player buildings + all biters/nests.
If you want to get ahold of me I'm almost always on Discord.
Re: A way to change Stats for Units in game?
I assume you want to make some promotion system for turrets. You could create different entity prototype for each rank and then promote the turret by fast replacing it with entity with higher rank.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: A way to change Stats for Units in game?
Is there a programatical way to do a fast replace? (The only way I know of currently is to make a copy of entity settings in a table, delete entity, place new entity, apply the stored settings).
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: A way to change Stats for Units in game?
Yes, http://lua-api.factorio.com/latest/LuaS ... ate_entity use the fast_replace=true option.aubergine18 wrote:Is there a programatical way to do a fast replace? (The only way I know of currently is to make a copy of entity settings in a table, delete entity, place new entity, apply the stored settings).
If you want to get ahold of me I'm almost always on Discord.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: A way to change Stats for Units in game?
Perfect! That will make my code much nicer 

Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.