How do I adjust the value of DATA in "control.lua"?
Using "data. Raw [******]" is invalid. Is there any other method?
thank you
How do I adjust the value of DATA in "control.lua"?
Re: How do I adjust the value of DATA in "control.lua"?
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.
Re: How do I adjust the value of DATA in "control.lua"?
Thank you. Although I don't quite understand it, I know my idea can't be realizedboskid wrote: ↑Thu Mar 03, 2022 10:54 amYou 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.
Re: How do I adjust the value of DATA in "control.lua"?
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!
Re: How do I adjust the value of DATA in "control.lua"?
Thank you. I think I probably understand what you meanPi-C wrote: ↑Thu Mar 03, 2022 1:16 pmI 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.