Inconsistent recipes

Place to get help with not working mods / modding interface.
Post Reply
BrokenScience
Inserter
Inserter
Posts: 26
Joined: Thu Jul 21, 2016 5:31 pm
Contact:

Inconsistent recipes

Post 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:
Image

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:
Image

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)
Smashing a brick wall with my face would be a lot more rewarding if I didn't just reveal 3 more.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Inconsistent recipes

Post 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()

BrokenScience
Inserter
Inserter
Posts: 26
Joined: Thu Jul 21, 2016 5:31 pm
Contact:

Re: Inconsistent recipes

Post 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.
Smashing a brick wall with my face would be a lot more rewarding if I didn't just reveal 3 more.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Inconsistent recipes

Post 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

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Inconsistent recipes

Post 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 :D

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.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Inconsistent recipes

Post 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 :D

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.

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Inconsistent recipes

Post 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 :D
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.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Inconsistent recipes

Post by Nexela »

orzelek wrote: Take a look at base game migrations :D
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?

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Inconsistent recipes

Post 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.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Inconsistent recipes

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: Inconsistent recipes

Post 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

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Inconsistent recipes

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Post Reply

Return to “Modding help”