Page 1 of 2

Editing recipes/result count

Posted: Mon Mar 04, 2013 6:50 pm
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

Re: Editing recipes/result count

Posted: Mon Mar 04, 2013 7:54 pm
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.

Re: Editing recipes/result count

Posted: Mon Mar 04, 2013 8:35 pm
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-

Re: Editing recipes/result count

Posted: Tue Mar 05, 2013 12:41 am
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.

Re: Editing recipes/result count

Posted: Sat Mar 16, 2013 12:57 am
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!

Re: Editing recipes/result count

Posted: Sat Mar 16, 2013 1:15 am
by kovarex
Andrea88 wrote:write your code and in "recipe-name" i must write "basic-transport-belt-to-ground"
Exactly.

Re: Editing recipes/result count

Posted: Sat Mar 16, 2013 10:21 am
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)

Re: Editing recipes/result count

Posted: Sat Mar 16, 2013 10:46 am
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.

Re: Editing recipes/result count

Posted: Sat Mar 16, 2013 11:15 am
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

Re: Editing recipes/result count

Posted: Sat Mar 16, 2013 11:20 am
by ficolas
"name-of-the-item" not name-of-the-item Remember the " "

Re: Editing recipes/result count

Posted: Sat Mar 16, 2013 11:48 am
by Andrea88
yes yes, i forgot the "" in my previous post, but in the ingame code i write them

Re: Editing recipes/result count

Posted: Sun Mar 17, 2013 3:22 am
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.

Re: Editing recipes/result count

Posted: Sun Mar 17, 2013 3:28 am
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?

Re: Editing recipes/result count

Posted: Sun Mar 17, 2013 11:18 am
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.

Re: Editing recipes/result count

Posted: Sun Mar 17, 2013 2:23 pm
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)

Re: Editing recipes/result count

Posted: Sun Mar 17, 2013 4:38 pm
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

Re: Editing recipes/result count

Posted: Tue Jul 02, 2013 11:41 pm
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 :)

Re: Editing recipes/result count

Posted: Wed Jul 03, 2013 3:49 am
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()

Re: Editing recipes/result count

Posted: Wed Jul 03, 2013 9:58 am
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!

Re: Editing recipes/result count

Posted: Wed Jul 03, 2013 4:08 pm
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.