Question about recipe reset

Place to get help with not working mods / modding interface.
Post Reply
Nasabot
Fast Inserter
Fast Inserter
Posts: 102
Joined: Fri Oct 30, 2015 11:16 am
Contact:

Question about recipe reset

Post by Nasabot »

Hello, I have another question with lua.

As some people might know there is a command you can use ingame to update modded recipe cost
/c game.player.force.reset_recipes()
My wish is to implement this code in the "command"-lua file so this command is done everytime the game starts(initializes)
With
script.on_init(init)
it can be done, but the problem is, that this wont work as exspected.

Imagine this:

-Original Laser turret recipe cost is 5 batteries
-Mod changes it to 8
If you start game manually and use "/c game.player.force.reset_recipes()" it works as expected->turret costs 8 batteries

If the savegame already has the recipes updated(8 batteries) and you add /c game.player.force.reset_recipes() in lua-command file and restart the game the cost is then resetted 5 batteries

The weird thing is, that other recipes dont get resetted to its original state. I will try around a little bit, also this problem is not too important but if anybody knows how to fix this, it would be nice.
bascially what I want to do is to automate "/c game.player.force.reset_recipes()" so if I update my mod and other people download it, they dont miss this "mandatory" input.

Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: Question about recipe reset

Post by Supercheese »

Instead of script.on_init, you should update the recipies in script.on_configuration_changed.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13223
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Question about recipe reset

Post by Rseding91 »

Supercheese wrote:Instead of script.on_init, you should update the recipies in script.on_configuration_changed.
In addition to this, migration scripts are meant for exactly this: you change something that needs to be dealt with on any game the mod is loaded into.

An example: https://github.com/Rseding91/Landfill/b ... /2.1.3.lua

In versions previous to Landfill 2.1.3 the water-be-gone recipe took only wood. I updated it to take a single electronic circuit in 2.1.3 so I added that migration file which the game applies (and only applies once) to any game loaded with the mod.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”