Page 1 of 1
Hidden Recipes available through blueprints
Posted: Sat Jan 18, 2020 4:47 am
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?
Re: Hidden Recipes available through blueprints
Posted: Sat Jan 18, 2020 7:52 am
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.
Re: Hidden Recipes available through blueprints
Posted: Sat Jan 18, 2020 12:01 pm
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.
Re: Hidden Recipes available through blueprints
Posted: Mon Jan 20, 2020 12:18 am
by lablet1
So I discovered I could just set the recipe equal to nil after removing them from all technologies and other recipes
Re: Hidden Recipes available through blueprints
Posted: Mon Jan 20, 2020 3:12 am
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?
Re: Hidden Recipes available through blueprints
Posted: Mon Jan 20, 2020 9:26 am
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.
Re: Hidden Recipes available through blueprints
Posted: Mon Jan 20, 2020 9:44 am
by Optera
Like Eradicator said, and it can't be stressed enough:
Never remove base prototypes!
Other mods will crash when referencing them.
Re: Hidden Recipes available through blueprints
Posted: Mon Apr 12, 2021 10:20 pm
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