Page 1 of 1

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

Posted: Sat Jun 20, 2020 3:51 pm
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!

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

Posted: Sat Jun 20, 2020 4:05 pm
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

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

Posted: Sat Jun 20, 2020 4:25 pm
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!