Hidden Recipes available through blueprints

Place to get help with not working mods / modding interface.
Post Reply
lablet1
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun May 19, 2019 7:27 pm
Contact:

Hidden Recipes available through blueprints

Post by lablet1 »

I am trying to disable a certain item from being crafted. To do this I am using:

Code: Select all

data.raw["recipe"]["item-name-here"].hidden = true
There are a couple of problems with this approach that I would like to fix.

1. if an old world is loaded up the assemblers that are already placed will still have the recipe in them. This recipe can then be copy pasted into new
assemblers, or into blueprints.

2. Even in a newly created world, the recipe can still be accessed using a blueprint containing an assembler using the recipe.

Is there a better simple approach to this or a fix to these problems?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Hidden Recipes available through blueprints

Post by eradicator »

To disable a recipe that was already unlocked previously you have to iterate through all forces and disable the recipe at runtime. Probably in on_init and/or on_config.

Code: Select all

--pseudocode
for _,f in pairs(game.forces) do 
  f.recipies['whatever'].enabled = false
  end
The hidden flag only prevents the recipes from being shown in the crafting menu, not from being used, nor from being unlocked by technologies at a later point.

An easier approach might be to simply set the crafting time to something ridiculously high so the recipes becomes *effectively* uncraftable.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Hidden Recipes available through blueprints

Post by Honktown »

A way to remove it from the world is to find_entities_filtered on all surfaces that have an entity prototype with the same crafting category, and void out that recipe (you can probably clear a recipe - not sure). Same could be done on blueprint related stuff. Would be more likely to work using on_built_entity in the context of blueprints, and have a table for which crafting machines one needs to check for the invalid recipe.
I have mods! I guess!
Link

lablet1
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun May 19, 2019 7:27 pm
Contact:

Re: Hidden Recipes available through blueprints

Post by lablet1 »

So I discovered I could just set the recipe equal to nil after removing them from all technologies and other recipes

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: Hidden Recipes available through blueprints

Post by Honktown »

lablet1 wrote:
Mon Jan 20, 2020 12:18 am
So I discovered I could just set the recipe equal to nil after removing them from all technologies and other recipes
Did it end up being removed and cleared from machines at the "migrated content" or whatever screen on load?
I have mods! I guess!
Link

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Hidden Recipes available through blueprints

Post by eradicator »

lablet1 wrote:
Mon Jan 20, 2020 12:18 am
So I discovered I could just set the recipe equal to nil after removing them from all technologies and other recipes
Sure, as long as you don't care about compatibility with other mods which might try to modifiy it.
In the OP it seemed like you wanted to just disable it without removing it completely.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Hidden Recipes available through blueprints

Post by Optera »

Like Eradicator said, and it can't be stressed enough:
Never remove base prototypes!

Other mods will crash when referencing them.

lablet1
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sun May 19, 2019 7:27 pm
Contact:

Re: Hidden Recipes available through blueprints

Post by lablet1 »

Optera wrote:
Mon Jan 20, 2020 9:44 am
Like Eradicator said, and it can't be stressed enough:
Never remove base prototypes!

Other mods will crash when referencing them.
My mod is not intended to be compatible with any mods that modify the logistics system

Post Reply

Return to “Modding help”