Page 1 of 1
Recipe, which requires 1,000 iron gear
Posted: Sun Mar 23, 2014 1:13 pm
by DRBLN
Is is possible to make an item in the machine if the recipe requires a lot of items?
e.g. 1,000 iron gears.
What should I edit to make it possible?
Re: Recipe, which requires 1,000 iron gear
Posted: Sun Mar 23, 2014 1:30 pm
by slay_mithos
The theory would point you in three possible ways:
1/ Make the iron gear stack up to 1024.
2/ Make intermediates that take like a full stack of iron gear per item.
3/ Change your way of thinking about prices, I can hardly see anything be useful enough to cost as much iron at once. But that's only because I have no clue about what you want to make.
A tip though, if you want help related to making a mod (or changing one), there is a sub section in the Mods forum dedicated to questions like that.
Re: Recipe, which requires 1,000 iron gear
Posted: Sun Mar 23, 2014 1:53 pm
by ficolas
or it would only be craftable by hand.
Re: Recipe, which requires 1,000 iron gear
Posted: Sun Mar 23, 2014 1:57 pm
by BurnHard
or you make a intermediate product. Eg gearbox which contains 64 gears. And for your final recipe you need 16 gearboxes
Re: Recipe, which requires 1,000 iron gear
Posted: Mon Mar 24, 2014 7:32 pm
by DRBLN
Please, advise how to increase the stack size.
Which file should I edit?
Re: Recipe, which requires 1,000 iron gear
Posted: Mon Mar 24, 2014 8:01 pm
by slay_mithos
You should never edit a base file, but in your mod, it would be something like:
Code: Select all
data.raw["item"]["iron-gear-wheel"].stack_size = 1024
It changes the property "stack_size" of the entry typed "item" and with the name "iron-gear-wheel".
Just so you know, this is the basic way of changing fields of existing entries in mods.
I hope I did not make mistake in my line though, that would be a bit embarrassing.
Re: Recipe, which requires 1,000 iron gear
Posted: Mon Mar 24, 2014 8:12 pm
by FreeER
First: moved this to the modding help section.
DRBLN wrote:Please, advise how to increase the stack size.
stack sizes are defined in the item prototypes. If you are adding a new item, that's where you'd change it, however, since the iron gears (your example) is from the base game, you should really use a data.raw edit rather than editing the file (that is if you want to distribute your mod or have it carry over between Factorio versions).
so for the iron gears you'd use this (basically) in your data.lua file (or a file that you require from data.lua)
Code: Select all
data.raw.item["iron-gear-wheel"].stack_size = 1024
or for safety and compatibility with other mods you'd really want to use
Code: Select all
if data.raw.item["iron-gear-wheel"]~=nil then
if data.raw.item["iron-gear-wheel"].stack_size < 1024 then
data.raw.item["iron-gear-wheel"].stack_size = 1024
end
end
The first if statement makes sure that the iron gear still exists in the base game and the second prevents you from rewriting it if another mod had already made it higher than what you needed (for instance, a mod that needed a stack size of 2048).
The name is in [""] because of the '-', if it had simply been "gear" then you use data.raw.item.gear.stack_size, but lua assumes that a '-' is only used for subtraction of variables and so causes issues if you do not use the [""] format.
You can see the layout of the data.raw table on the wiki
here (though it may not be completely up to date with 9.4).
edit: looks like slay_mithos beat me to it
oh well.
Re: Recipe, which requires 1,000 iron gear
Posted: Wed Mar 26, 2014 4:14 am
by DRBLN
Is it possible to apply the change to the saved game?
Re: Recipe, which requires 1,000 iron gear
Posted: Wed Mar 26, 2014 4:30 am
by FreeER
you can use game.player.force.resetrecipes() (there is a resettechnologies as well, should you need it) to make the save use the changed prototypes, it can be run in the console if it's just your save, but if you have\had given the mod to others you'd want to place it in a lua migration script instead of telling everyone to open the console and type run it themselves.
Re: Recipe, which requires 1,000 iron gear
Posted: Wed Mar 26, 2014 6:13 am
by AlexPhoenix
not better to reset only needed recipes?
Re: Recipe, which requires 1,000 iron gear
Posted: Sat Mar 29, 2014 2:19 pm
by DRBLN
Please, could you share the list of the names of all items used in the game?
Re: Recipe, which requires 1,000 iron gear
Posted: Sat Mar 29, 2014 2:23 pm
by DRBLN
Is it essential to make the stack size divisible by 16?
Re: Recipe, which requires 1,000 iron gear
Posted: Sat Mar 29, 2014 3:40 pm
by FreeER
DRBLN wrote:Please, could you share the list of the names of all items used in the game?
I don't currently have one made up, but you could open all the files in data\base\prototypes\item (these are where all the items are defined) or the locale(s) should list the vast majority of the items data\base\locale\en\item-names.cfg or (though only covering up to 8.8) the
data.raw page on the wiki, under the heading 'item'.
DRBLN wrote:Is it essential to make the stack size divisible by 16?
I think it the stack size needs to be a power of 2 (aka, 2^6=64 and 2^8=256, 2^10 is 1024). But I'm not actually sure.
Re: Recipe, which requires 1,000 iron gear
Posted: Sat Mar 29, 2014 3:50 pm
by DRBLN
Well, I tried to make it 5,000
Works fine
Please, advise how do I apply that modification in the saved game.
Re: Recipe, which requires 1,000 iron gear
Posted: Sat Mar 29, 2014 5:34 pm
by FreeER
DRBLN wrote:Well, I tried to make it 5,000
Works fine
Good to know, thanks for sharing.
Please, advise how do I apply that modification in the saved game.
note: this should work..Pre-mod release you can use the console (~ or / in game, at least for most keyboards) and type
and if you changed any technologies
Code: Select all
game.player.force.resettechnologies()
AFTER mod release(s) you should create a lua migration script (any name ending with .lua, within a 'migrations' folder inside your mod) and simply add the same line(s), so that it is automatically done for saves that need it.
If that didn't work then you might have to use game.player.force.reset(), but that will set any researched technology back to un-researched...
Re: Recipe, which requires 1,000 iron gear
Posted: Sat Mar 29, 2014 6:03 pm
by DRBLN
Thank you.
It helped