Scripting help with recipes

Place to get help with not working mods / modding interface.
spacedestructor
Inserter
Inserter
Posts: 20
Joined: Sat Aug 19, 2017 6:06 pm
Contact:

Scripting help with recipes

Post by spacedestructor »

I hope this hasnt been asked before but i made a little mod that helps me testing production setups by providing in a cheat the resources necessary to keep it running.
Now when i want to write in the script features for the user to customize the mod experience i run in the issue for example that when i make a setting to change if it should show up in the production overview or not the game doesnt change the behavior if it shows up or not.
I already debugged the script and tested out enough to confirm the code works and it does exactly what i want to do but the game doesnt update, so my question is what things are that i cant change after a save has been started in the prototype info. in general for all prototypes but most importantly for entities, recipes and technology.
Was trying to look this up but could find no info on this on the Wiki and nowhere else, so i hope someone can let me know of the limits what i can do so i know what i need to move to start up settings and what i can keep in per player or global.
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2767
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Scripting help with recipes

Post by FuryoftheStars »

This is an incomplete answer, but prototypes cannot be altered outside of the data stage. Some things, like entities, take a copy of the prototype and will allow editing of some of their values for that specific entity, but you'd have to check out the API docs to know for sure which ones allow this (the property will have a grey " [RW] " by them).

But more specifically about recipes, afaik, they cannot be altered in any way after the data stage.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
spacedestructor
Inserter
Inserter
Posts: 20
Joined: Sat Aug 19, 2017 6:06 pm
Contact:

Re: Scripting help with recipes

Post by spacedestructor »

FuryoftheStars wrote: Fri Feb 18, 2022 5:16 am This is an incomplete answer, but prototypes cannot be altered outside of the data stage. Some things, like entities, take a copy of the prototype and will allow editing of some of their values for that specific entity, but you'd have to check out the API docs to know for sure which ones allow this (the property will have a grey " [RW] " by them).

But more specifically about recipes, afaik, they cannot be altered in any way after the data stage.
I was using the API documentation for the scripting work before but beside a mention in the Wiki at what stage during the loading you can access what information and how there isnt much info on Limitations besides an odd mention here and there that despite being marked as read only you can also write to some of them which is i believe also mentioned a few times in the Api documentation but the Api documentation has no info directly saying or hinting at it that i cant change prototypes on runtime.
One last question, i think i can guess the answer to this but i just want to be sure: That it cant be changed during Runtime means if the Setting is Saved and then the Game Restarted the new setting will be applied during loading right?
Thanks in advance for the Help. you have been very helpful at telling me why my script doesnt get the desired result where both the Wiki and the Docs fail to Mention this at all.
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2767
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Scripting help with recipes

Post by FuryoftheStars »

spacedestructor wrote: Fri Feb 18, 2022 5:36 am if the Setting is Saved and then the Game Restarted the new setting will be applied during loading right?
Correct.

And one addendum/correction to my previous post. One thing about recipes that can be changed at runtime is whether or not they are enabled.

One thing to keep in mind is that (for prototypes) everything has a data stage version and then a runtime version. When looking through the docs, make sure you know which one you're looking at.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
spacedestructor
Inserter
Inserter
Posts: 20
Joined: Sat Aug 19, 2017 6:06 pm
Contact:

Re: Scripting help with recipes

Post by spacedestructor »

FuryoftheStars wrote: Fri Feb 18, 2022 7:22 am
Correct.

And one addendum/correction to my previous post. One thing about recipes that can be changed at runtime is whether or not they are enabled.

One thing to keep in mind is that (for prototypes) everything has a data stage version and then a runtime version. When looking through the docs, make sure you know which one you're looking at.
again thanks a lot for this valuable information, i think you helped me a lot in understanding how factorio or at least the part relevant to me works. at least i can break the roadblock and make more progress again until i have to come back in the forum with more questions. :D
Post Reply

Return to “Modding help”