How do I adjust the value of DATA in "control.lua"?

Place to get help with not working mods / modding interface.
Post Reply
sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

How do I adjust the value of DATA in "control.lua"?

Post by sdgmlj »

How do I adjust the value of DATA in "control.lua"?
Using "data. Raw [******]" is invalid. Is there any other method?
thank you

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2252
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: How do I adjust the value of DATA in "control.lua"?

Post by boskid »

You cannot. This is one of the principles of working with prototypes. Prototypes are defined at data stage and after that they are immutable. If they would be mutable they would need to be saved in a save file which we are not doing, when changing mods there would be a need for a mechianism to choose which values of prototypes should be taken from changed mods and which from the save file, everything would need to be aware that a prototype may change so some interactions would need to happen. This is just not allowed. Period.

sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: How do I adjust the value of DATA in "control.lua"?

Post by sdgmlj »

boskid wrote:
Thu Mar 03, 2022 10:54 am
You cannot. This is one of the principles of working with prototypes. Prototypes are defined at data stage and after that they are immutable. If they would be mutable they would need to be saved in a save file which we are not doing, when changing mods there would be a need for a mechianism to choose which values of prototypes should be taken from changed mods and which from the save file, everything would need to be aware that a prototype may change so some interactions would need to happen. This is just not allowed. Period.
Thank you. Although I don't quite understand it, I know my idea can't be realized

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

Re: How do I adjust the value of DATA in "control.lua"?

Post by Pi-C »

sdgmlj wrote:
Thu Mar 03, 2022 11:16 am
Although I don't quite understand it, I know my idea can't be realized
I suppose you want to change certain properties of entities in response to some event or player action. While you can't modify prototype definitions in the control stage, you could define different versions of your main prototype in the data stage and swap entities during control.

For example, in the water turret mod, I've defined two different versions of the flamethrower turret prototype (one shooting water, the other steam) in the data stage. Both turrets look alike. Also, there's only one recipe and it will always produce a water turret. In the control stage, I regularly check what fluid each of these turrets is connected to. When there's steam in the pipe that feeds a water turret, I remove it and put down a steam turret instead (and vice versa). I also copy properties like the current health or the number of kills, so players shouldn't even notice that there are two different versions of that turret in the game.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: How do I adjust the value of DATA in "control.lua"?

Post by sdgmlj »

Pi-C wrote:
Thu Mar 03, 2022 1:16 pm
sdgmlj wrote:
Thu Mar 03, 2022 11:16 am
Although I don't quite understand it, I know my idea can't be realized
I suppose you want to change certain properties of entities in response to some event or player action. While you can't modify prototype definitions in the control stage, you could define different versions of your main prototype in the data stage and swap entities during control.

For example, in the water turret mod, I've defined two different versions of the flamethrower turret prototype (one shooting water, the other steam) in the data stage. Both turrets look alike. Also, there's only one recipe and it will always produce a water turret. In the control stage, I regularly check what fluid each of these turrets is connected to. When there's steam in the pipe that feeds a water turret, I remove it and put down a steam turret instead (and vice versa). I also copy properties like the current health or the number of kills, so players shouldn't even notice that there are two different versions of that turret in the game.
Thank you. I think I probably understand what you mean

Post Reply

Return to “Modding help”