Editing recipes/result count

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Editing recipes/result count

Post by Andrea88 »

Hello everyone! I'm from Italy so forgive me for my english :) naturally, i'll do my best eheheh!!

well, i need 2 underground lines. I click twice and it goes. But if i want craft 2 underground lines together/at a time, hoow can i do?
I looked for the repice file, i added the line

Code: Select all

"result-count": 2
but it doesn't work. Any ideas?
Thanks a lot.

PS. in some recipes, there is the line

Code: Select all

"enabled": "true"
or "false", it depends. What does it mean?
Thanks.

Andrea

wrtlprnft
Fast Inserter
Fast Inserter
Posts: 155
Joined: Thu Feb 21, 2013 8:49 pm
Contact:

Re: Editing recipes/result count

Post by wrtlprnft »

Did you start a new game to test your modification? Oddly, modifying recipes only seems to affect assembling machines in already existing games, not manual crafting.

The enabled line refers to whether you can initially craft that recipe, even without researching anything.

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Editing recipes/result count

Post by Andrea88 »

thanks a lot for the reply!
no, i don't try to start a new game... i'm sorry for my save: i made so many things... :roll: However i'll try start a new game and i'll come back here with the results. Also, NOW i try to put underground assembly line in "autocrafting" and see what happens.

Thanks again for all!

-EDIT-

i confirm: all modifications about recipes, only works putting items into crafting machine and not opening the inventory using the "hand crafting".
probably you're right, i need to start a new game to take my modifications effective.

-END EDIT-

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Editing recipes/result count

Post by kovarex »

For more information about recipes, I wrote some basic info here:
https://forums.factorio.com/wiki/inde ... son/recipe

The current system is, that when game starts, all forces (players) get their copy of default recipes.
After that, no changes of the original recipes will affect players (only adding new recipes).
There is good reason for that, as at this point, every player could have different recipes (there are plans to change recipes using lua, and to change recipes for players that researched some technology), so they need to have the copy.

Anyway, there is a way to test the changed recipe without restarting the game, type in console (~)

Code: Select all

game.getplayer().force.getrecipes()["recipe-name"].reload()
This will reload the recipe from the prototype.

I hope this helps.

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Editing recipes/result count

Post by Andrea88 »

@kovarex:
well, i read the wiki you linked and i tried the console command but i can't let him work :(
I'm a bit confused about <<[recipe-name]>> in the command. What do i write in there?
Using the example in my first post (result 2 underground conveior belts instead 1), i open the "recipe.json" file, add the line <<"result-count": 2>> to the recipe named "basic-transport-belt-to-ground" and save. Once reloaded the previous savegame, i open the console, write your code and in "recipe-name" i must write "basic-transport-belt-to-ground"? Or am i wrong?
Thanks for all!

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Editing recipes/result count

Post by kovarex »

Andrea88 wrote:write your code and in "recipe-name" i must write "basic-transport-belt-to-ground"
Exactly.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Editing recipes/result count

Post by ficolas »

Did this change from 0.2.8 to 0.2.10? because I was able to test my mod iin 0.2.8 without creating new files (modifying the control.lua)

SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: Editing recipes/result count

Post by SilverWarior »

When you are changing LUA files those changes usually don't require game restart but only reloading those scripts.
But when you are doing changes to JSON files game restart or athleast reloading the level is required.
This is becouse JSON files actually defines ingame classes.
Class is actually managed block of memory usually caled an object. When I say managed I mean that class doesn't just simply store data in its variables as records does but it can also provide methods for further processing this stored data.
So if you wan't some changes in class definition to be afected in the game you need to recreate those classes which usually isn't easy since other classes may depend on functionality of the class you have been chaning therefore the safest way is to recreate all the clases even if their definitions hasnt been changed.
In other words this usually means athleast reloading the level.

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Editing recipes/result count

Post by Andrea88 »

@kovarex:
thanks for the reply! i'm using 0.2.10 alpha version, but the command won't run. The error is:

Code: Select all

cannot execute command. error: [string "game.getplayer()....*everything else of code*....to-gound]:1:LuaRecipe::luaIndex:unknow key reload
Naturally, if i try to delete reload() function, it gives me

Code: Select all

syntax error near <eof>
Any suggestion?
thanks

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Editing recipes/result count

Post by ficolas »

"name-of-the-item" not name-of-the-item Remember the " "

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Editing recipes/result count

Post by Andrea88 »

yes yes, i forgot the "" in my previous post, but in the ingame code i write them

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Editing recipes/result count

Post by kovarex »

I'm sorry for the misdirection, I just checked it and the reload function is actually implemented only for the LuaTechnology not for the LuaRecipe.
I will add this function to the next release, but for now, there is no way to do it.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Editing recipes/result count

Post by FreeER »

I'm assuming (until the next release anyway) that you could not try to disable and then re-enable to get it to reload the recipe?
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Editing recipes/result count

Post by Andrea88 »

kovarex wrote:I'm sorry for the misdirection, I just checked it and the reload function is actually implemented only for the LuaTechnology not for the LuaRecipe.
I will add this function to the next release, but for now, there is no way to do it.
Thanks for checking.. I was confused when the code you gave me didn't work :) In fact the error says "unknow key reload". Understood.
ok, so whenever i edit a recipe (item craftable from the player inventory), must i start a new game to let it work? while the recipe will work if i put it in assembling machine without new game. right?
Regards.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Editing recipes/result count

Post by kovarex »

There is more drastical way to do it, you can do:

Code: Select all

game.getplayer().resetrecipes()
This reloads all recipes for the player.

(Btw when I look at this, I need to move this method to force)

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Editing recipes/result count

Post by Andrea88 »

yeah! so it works fine! thanks a lot! :D
in this way, ALL recipes will be "reloaded"? So i don't need to reload one recipe at time. wonderful, just what i was looking for. yeah, because sometimes i edit my new recipes more times.
Continue to develop the game, men, you're making a veeeery good work! :D :D

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Editing recipes/result count

Post by Andrea88 »

Hey! I re-open this thread because the code used in 0.2.10 alpha

Code: Select all

game.getplayer().resetrecipes()
is not longer working in 0.5.2 alpha

I just have to do the same thing: reload the recipe wrote in the 1st post :D coud someone help me please? Thanks in advance :)

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: Editing recipes/result count

Post by slpwnd »

This has been moved to force, so now it is:

Code: Select all

game.player.force.resetrecipes()
If you want to reload just one recipe then:

Code: Select all

game.player.force.recipes["YOUR-RECIPE-NAME-HERE"].reload()

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Editing recipes/result count

Post by Andrea88 »

slpwnd thank you very much, it works perfectly! now i can continue my world.... btw, a suggest (maybe wrong section :P): what do you say to permanently modify this recipe? 2 underground belts instead 1.

thx again!

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: Editing recipes/result count

Post by slpwnd »

Hmm most of the time you actually want them in pairs. That is true. However I can imagine situations when you want just one and the other one is of a different color.

Post Reply

Return to “Gameplay Help”