Page 1 of 1
Inconsistent recipes
Posted: Tue Jan 10, 2017 1:49 am
by BrokenScience
Some of my recipes refuse to update and I cant seem to add any recipe unlocks to the already existing techs. They either have a "Base > myMod" in yellow underneath or are just different than the one currently in my files, sometimes both.
Here is an example of one of the segments I have with this problem:
Code: Select all
{
type = "recipe",
name = "market",
enabled = false,
ingredients =
{
{"electronic-circuit", 20},
{"iron-plate", 100},
{"copper-cable", 50},
},
energy_required = 10,
result = "market",
},
And here is what is actually displays as:
The main problem I have with this one is the time it takes to craft. It should take 10 seconds, but only takes 0.5. I have others that don't even have the same recipes as the code I have for it that I can't explain.
Here is one example:
Code: Select all
{
type = "recipe",
name = "portal-piece",
enabled = false,
ingredients =
{
{"copper-cable", 20},
{"iron-plate", 10},
{"electronic-circuit", 10},
},
result = "portal-piece",
},
And this is the recipe the game has for it:
This one's recipe has alien artifacts in the game that are no longer in my table that for some reason refuse to change. (turning it off and on again doesn't work, I tried)
Re: Inconsistent recipes
Posted: Tue Jan 10, 2017 2:56 am
by Nexela
Unless you change the version # of your mod (or add remove upgrade other mods) you will have to run these commands to force an update of your recipes/technologies
/c game.player.force.reset_technologies()
/c game.player.force.reset_recipes()
Re: Inconsistent recipes
Posted: Tue Jan 10, 2017 3:47 am
by BrokenScience
Does the "base > myMod" just mean that myMod edited this such that Base(mod thing came from) > myMod(mod that edited this) where any other mods that modded this would simply come after? That would explain why it showed up on my market item and entity as they were edits of the already in-game version.
Re: Inconsistent recipes
Posted: Tue Jan 10, 2017 4:38 am
by Nexela
Any mod that edits something is flagged in such a way in the order of the mod that changed it I think anyway.
Base -> MyMod -> OtherMod Means that MyMod edited something about the base game prototype, OtherMod edited something about the MyMod prototype
Re: Inconsistent recipes
Posted: Tue Jan 10, 2017 5:52 pm
by orzelek
Nexela wrote:Unless you change the version # of your mod (or add remove upgrade other mods) you will have to run these commands to force an update of your recipes/technologies
/c game.player.force.reset_technologies()
/c game.player.force.reset_recipes()
Disclaimer: stuff below based on my limited usage of migrations
This is not entirely true - it's all in migration files.
Adding new migration with those commands should make it run those any time save is loaded if this migration has not been run before. I'm not sure how it will interact with order of migrations (see how base game names migrations in format with date then factorio and version).
Also if you add new recipe to tech that has been already researched in game you will need to check for this and enable this recipe in migration file. Reset of recipes and technologies won't do that for you.
Re: Inconsistent recipes
Posted: Tue Jan 10, 2017 8:25 pm
by Nexela
orzelek wrote:Nexela wrote:Unless you change the version # of your mod (or add remove upgrade other mods) you will have to run these commands to force an update of your recipes/technologies
/c game.player.force.reset_technologies()
/c game.player.force.reset_recipes()
Disclaimer: stuff below based on my limited usage of migrations
This is not entirely true - it's all in migration files.
Adding new migration with those commands should make it run those any time save is loaded if this migration has not been run before. I'm not sure how it will interact with order of migrations (see how base game names migrations in format with date then factorio and version).
Also if you add new recipe to tech that has been already researched in game you will need to check for this and enable this recipe in migration file. Reset of recipes and technologies won't do that for you.
I think the reset_technologies/reset_recipes is ran automagicly every time the game version/mods version change. I could be wrong and it could be another mod that is running those without me knowing :p
The migration files I believe are only ran if the game/mod version changes (and if the migration has not run before)
if you change recipes in your mod without changing version numbers you will have to run the above code for the changes to show up. Also if your save already has the technology researched any new recipes will have to be manually enabled. Migration files are created to do this automatically when your mod version changes as stated by Orzelek.
Re: Inconsistent recipes
Posted: Tue Jan 10, 2017 8:50 pm
by orzelek
Nexela wrote:
I think the reset_technologies/reset_recipes is ran automagicly every time the game version/mods version change. I could be wrong and it could be another mod that is running those without me knowing :p
Take a look at base game migrations

From what I have seen simple version change doesn't do anything. Reset needs to be actually coded in migration.
Also version change of mod is not required to run migration. If you add migration to mod and load a game with it that migration will be run and then save will be marked that it had this migration. I played around with this one recently to not restart my AnonyMods save file.
Re: Inconsistent recipes
Posted: Tue Jan 10, 2017 9:34 pm
by Nexela
orzelek wrote:
Take a look at base game migrations

From what I have seen simple version change doesn't do anything. Reset needs to be actually coded in migration.
https://www.reddit.com/r/factorio/comme ... w/d0i32ab/
Also version change of mod is not required to run migration. If you add migration to mod and load a game with it that migration will be run and then save will be marked that it had this migration. I played around with this one recently to not restart my AnonyMods save file.
Interesting to know about migrations. but it could get kind of clunky
Mod with migration_1.0.0
New game - migration runs
Save game
Edit Mod without changing version #
New migration migration2_1.0.0
Load earlier game migration2 runs?
Re: Inconsistent recipes
Posted: Tue Jan 10, 2017 11:11 pm
by orzelek
The auto recipe reset I did not know about and it's good to know.
Additional migrations are only useful for emergency fixing of stuff. Normally you'd use only one per version along with new release.
And yes earlier game would run both migrations since state is per migration not per version as far as I understood.
Re: Inconsistent recipes
Posted: Wed Jan 11, 2017 3:15 pm
by bobingabout
Yeah. Since version 13.0 I think it was, the game was changed to run a recipe/technology updates script when the mod version number was changed.
As for Migrations, I'm fairly sure this is the order:
All .json replacement scripts are run first, in alphabetical order.
THEN
All .LUA scripts are run in alphabetical order.
If one script fails, I think it just abandons that one script, but I'm not certain, it's possible it will abandon them all from that mod.
And as mentioned, each script is only ever run once. once it has been run, it is recorded and never run again on that save game.
Re: Inconsistent recipes
Posted: Wed Jan 11, 2017 5:11 pm
by matjojo
when testing I'd say it's handy to make a hotkey that points to the things you want to reset when loading the map
Re: Inconsistent recipes
Posted: Thu Jan 12, 2017 9:49 am
by bobingabout
Yeah, that's not a bad idea. you can add events caused by key presses to the game. Write in a key press event that runs reset recipes and reset technologies, so when you're constantly changing mods you can press the hotkey on game load instead of having to constantly rename migration scripts.