Is it possible to change the prototype of an entity during a game?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Philuminati
Inserter
Inserter
Posts: 35
Joined: Sun Aug 05, 2018 1:04 am
Contact:

Is it possible to change the prototype of an entity during a game?

Post by Philuminati »

Hello,

I try to make a mod that makes trains look different depending on their fuel. My question now is: How do I change the properties of e.g. the front lights of a locomotive in a script in a running game?

Thanks in advance,

Phil

Pi-C
Smart Inserter
Smart Inserter
Posts: 1645
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Is it possible to change the prototype of an entity during a game?

Post by Pi-C »

Hi!
Philuminati wrote:
Fri Jul 31, 2020 2:39 pm
I try to make a mod that makes trains look different depending on their fuel. My question now is: How do I change the properties of e.g. the front lights of a locomotive in a script in a running game?
You should probably make a copy of the locomotive during the data stage and then swap the entities (create clone of the first entity, then destroy the original) during control. Don't forget to raise an event in that case, so other mods have a chance to update their tables!

By the way, that's how these things are usually done. I don't know if it will also work with trains -- could well be that problems would occur if the train was moving.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Modding help”