Possible bug? Setting data.raw.recipe["submachine-gun"].hidden = true doesn't hide the recipe

Place to get help with not working mods / modding interface.
stever1388
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Jun 16, 2020 10:06 pm
Contact:

Possible bug? Setting data.raw.recipe["submachine-gun"].hidden = true doesn't hide the recipe

Post by stever1388 »

I'm working on a mod that hides most military technology and items, and I'm doing that by setting the technologies, recipes, and items to hidden using the following code:

Code: Select all

-- in data.lua
data.raw.recipe["submachine-gun"].hidden = true -- hide the submachine gun from the crafting menus
data.raw["gun"]["submachine-gun"].flags = { "hidden" } -- hide the submachine gun item from filter menus (e.g., requester chests)
data.raw.technology["military"].hidden = true -- hide the military technology
This works for 95% of the items/recipes/technologies. However, for some reason setting the following recipes to be hidden doesn't actually work:

Code: Select all

-- in data.lua
data.raw.recipe["submachine-gun"].hidden = true
data.raw.recipe["tank"].hidden = true
data.raw.recipe["cannon-shell"].hidden = true
data.raw.recipe["explosive-cannon-shell"].hidden = true
In game, if I open up the console and type the following, it will return false, even though I have set the prototype to be hidden in data.lua.

Code: Select all

-- in game console
/c game.print(game.player.force.recipes["submachine-gun"].prototype.hidden) -- prints false
Doing the same thing with the pistol works:

Code: Select all

-- in data.lua
data.raw.recipe["pistol"].hidden = true

Code: Select all

-- in game console
/c game.print(game.player.force.recipes["pistol"].prototype.hidden) -- prints true
I don't have any other mods active at all, so it's not another mod altering the settings. I'm also starting up a fresh save to make sure it's not caused by previously loaded mods or other factors.

I could be doing something wrong, but it seems to work for all the other recipes. Just those 4 recipes (that I have found so far at least) don't seem to hide correctly. Setting the hidden flag to the item itself works - so the items don't show up in filters, but the recipes stills show up in the crafting menus.

This is in Factorio v0.18.32.

Any ideas? Thanks!
Rseding91
Factorio Staff
Factorio Staff
Posts: 14323
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Possible bug? Setting data.raw.recipe["submachine-gun"].hidden = true doesn't hide the recipe

Post by Rseding91 »

You aren't setting hidden on the correct section. Those recipes are defined using the difficulties system: https://wiki.factorio.com/Prototype/Recipe#normal
If you want to get ahold of me I'm almost always on Discord.
stever1388
Burner Inserter
Burner Inserter
Posts: 5
Joined: Tue Jun 16, 2020 10:06 pm
Contact:

Re: Possible bug? Setting data.raw.recipe["submachine-gun"].hidden = true doesn't hide the recipe

Post by stever1388 »

Rseding91 wrote: Sat Jun 20, 2020 4:05 pm You aren't setting hidden on the correct section. Those recipes are defined using the difficulties system: https://wiki.factorio.com/Prototype/Recipe#normal
Yep that does the trick. Thanks!
Post Reply

Return to “Modding help”