Page 1 of 1

A way to change Stats for Units in game?

Posted: Sun Jan 22, 2017 3:41 pm
by Dobudakter
How to change the max_health of a turret with many kills, for example?

Re: A way to change Stats for Units in game?

Posted: Sun Jan 22, 2017 4:03 pm
by Rseding91
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.

Re: A way to change Stats for Units in game?

Posted: Sun Jan 22, 2017 5:38 pm
by posila
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.

Re: A way to change Stats for Units in game?

Posted: Wed Feb 01, 2017 11:26 pm
by aubergine18
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).

Re: A way to change Stats for Units in game?

Posted: Wed Feb 01, 2017 11:28 pm
by Rseding91
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).
Yes, http://lua-api.factorio.com/latest/LuaS ... ate_entity use the fast_replace=true option.

Re: A way to change Stats for Units in game?

Posted: Thu Feb 02, 2017 12:11 am
by aubergine18
Perfect! That will make my code much nicer :D