Recipe, which requires 1,000 iron gear

Place to get help with not working mods / modding interface.
Post Reply
DRBLN
Filter Inserter
Filter Inserter
Posts: 411
Joined: Sat Mar 23, 2013 12:44 pm
Contact:

Recipe, which requires 1,000 iron gear

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

slay_mithos
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Feb 25, 2014 7:22 am
Contact:

Re: Recipe, which requires 1,000 iron gear

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

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

Re: Recipe, which requires 1,000 iron gear

Post by ficolas »

or it would only be craftable by hand.

BurnHard
Filter Inserter
Filter Inserter
Posts: 519
Joined: Mon Oct 21, 2013 5:08 pm
Contact:

Re: Recipe, which requires 1,000 iron gear

Post by BurnHard »

or you make a intermediate product. Eg gearbox which contains 64 gears. And for your final recipe you need 16 gearboxes

DRBLN
Filter Inserter
Filter Inserter
Posts: 411
Joined: Sat Mar 23, 2013 12:44 pm
Contact:

Re: Recipe, which requires 1,000 iron gear

Post by DRBLN »

Please, advise how to increase the stack size.
Which file should I edit?

slay_mithos
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Feb 25, 2014 7:22 am
Contact:

Re: Recipe, which requires 1,000 iron gear

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

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

Re: Recipe, which requires 1,000 iron gear

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

DRBLN
Filter Inserter
Filter Inserter
Posts: 411
Joined: Sat Mar 23, 2013 12:44 pm
Contact:

Re: Recipe, which requires 1,000 iron gear

Post by DRBLN »

Is it possible to apply the change to the saved game?

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

Re: Recipe, which requires 1,000 iron gear

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

User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: Recipe, which requires 1,000 iron gear

Post by AlexPhoenix »

not better to reset only needed recipes?

DRBLN
Filter Inserter
Filter Inserter
Posts: 411
Joined: Sat Mar 23, 2013 12:44 pm
Contact:

Re: Recipe, which requires 1,000 iron gear

Post by DRBLN »

Please, could you share the list of the names of all items used in the game?

DRBLN
Filter Inserter
Filter Inserter
Posts: 411
Joined: Sat Mar 23, 2013 12:44 pm
Contact:

Re: Recipe, which requires 1,000 iron gear

Post by DRBLN »

Is it essential to make the stack size divisible by 16?

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

Re: Recipe, which requires 1,000 iron gear

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

DRBLN
Filter Inserter
Filter Inserter
Posts: 411
Joined: Sat Mar 23, 2013 12:44 pm
Contact:

Re: Recipe, which requires 1,000 iron gear

Post by DRBLN »

Well, I tried to make it 5,000
Works fine

Please, advise how do I apply that modification in the saved game.

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

Re: Recipe, which requires 1,000 iron gear

Post 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

Code: Select all

game.player.force.resetrecipes()
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...

DRBLN
Filter Inserter
Filter Inserter
Posts: 411
Joined: Sat Mar 23, 2013 12:44 pm
Contact:

Re: Recipe, which requires 1,000 iron gear

Post by DRBLN »

Thank you.
It helped

Post Reply

Return to “Modding help”