How do I remove something and everything that refers to it without having to do it all manually?

Place to get help with not working mods / modding interface.
000
Inserter
Inserter
Posts: 33
Joined: Mon Dec 27, 2021 5:00 pm
Contact:

How do I remove something and everything that refers to it without having to do it all manually?

Post by 000 »

Or: How do I wildcard repetitive data.raw rules?

I am working on a mod in which all Intermediate items and crafting recipes will have no use, because every recipe that would use them will use items added by my mod instead, which I am splitting across their own crafting tabs. I have already found a thread on how to add new tabs, and its method works.

I want to hide the Intermediates tab in the crafting interface to prevent confusion and clutter. Ideally, I also want these items and recipes to not appear in the Factoriopedia for the same reason.

Thanks to How Do I Delete a Recipe or Item From Vanilla?, I know that I can do:

Code: Select all

data.raw["item-group"]["intermediate-products"] = nil
This does work. However, the game throws an error, blaming my mod for removing this category. The source of this error is apparently fluid-recipes.

Thanks to Darkfrei I know I must remove the referents throwing this error. That makes sense. I do:

Code: Select all

data.raw["item-subgroup"]["fluid-recipes"] = nil
data.raw["item-subgroup"]["raw-resource"] = nil
data.raw["item-subgroup"]["raw-material"] = nil
data.raw["item-subgroup"]["barrel"] = nil
data.raw["item-subgroup"]["fill-barrel"] = nil
data.raw["item-subgroup"]["empty-barrel"] = nil
data.raw["item-subgroup"]["intermediate-products"] = nil
data.raw["item-subgroup"]["intermediate-recipe"] = nil
data.raw["item-subgroup"]["uranium-processing"] = nil
data.raw["item-subgroup"]["science-pack"] = nil
data.raw["item-subgroup"]["internal-process"] = nil
This works. However, a new error. Now the problem is wood. I can see where this is going, and having re-read Darkfrei's answer I realise I should have expected this.

I have to set every intermediate item, and every intermediate recipe, to nil.

I can, but surely I'm missing something. Surely there's a simple way to do

Code: Select all

data.raw["item-group"]["intermediate-products"][*] = nil
I did try that, but this throws the error "unexpected symbol near *".

If there is clear, detailed documentation on how to use data.raw, I'd appreciate a link. Modders seem to know instinctively how to use it, and I cannot figure out how they know this stuff! For instance, I've found that it cannot be used to replace an image, even though it looks as though it could.
User avatar
Osmo
Filter Inserter
Filter Inserter
Posts: 361
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: How do I remove something and everything that refers to it without having to do it all manually?

Post by Osmo »

simply set the hidden, as well as hidden_in_factoriopedia properties to true instead of deleting the prototypes
https://lua-api.factorio.com/latest/pro ... tml#hidden
000
Inserter
Inserter
Posts: 33
Joined: Mon Dec 27, 2021 5:00 pm
Contact:

Re: How do I remove something and everything that refers to it without having to do it all manually?

Post by 000 »

Osmo wrote: Sun Sep 20, 2026 12:42 am simply set the hidden, as well as hidden_in_factoriopedia properties to true instead of deleting the prototypes
https://lua-api.factorio.com/latest/pro ... tml#hidden
Thank you for reply.

I must be doing something wrong. I tried:

Code: Select all

data.raw["item-group"]["intermediate-products"].hidden = true
data.raw["item-group"]["intermediate-products"].hidden_in_factoriopedia = true
This does nothing. The Intermediates tab remains visible.

What is the proper way of doing this please?
User avatar
Osmo
Filter Inserter
Filter Inserter
Posts: 361
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: How do I remove something and everything that refers to it without having to do it all manually?

Post by Osmo »

000 wrote: Mon Sep 21, 2026 8:55 pm

Code: Select all

data.raw["item-group"]["intermediate-products"].hidden = true
data.raw["item-group"]["intermediate-products"].hidden_in_factoriopedia = true
This does nothing. The Intermediates tab remains visible.
First thing is to make sure the changes are actually applied in-game. You can use prototype explorer (Ctrl+Shift+F while hovering over something or Ctrl+Shift+E) to verify the game says they are indeed hidden.

But also the hidden property might not apply to all prototype types. For example, it doesn't make a lot of sense for item groups to be hidden, as if they have no items, they will not be visible anyway, but if they do have items, it doesn't make sense to not display them.
000
Inserter
Inserter
Posts: 33
Joined: Mon Dec 27, 2021 5:00 pm
Contact:

Re: How do I remove something and everything that refers to it without having to do it all manually?

Post by 000 »

I appreciate the tip about the prototype explorer! This will be very helpful.

Using that, I can see the "item-group" prototype "intermediate-products" has both hidden and hidden_in_factoriopedia as true.

Looking at other item groups (such as Logistics), these values are false.
Osmo wrote: Tue Sep 22, 2026 1:09 am But also the hidden property might not apply to all prototype types. For example, it doesn't make a lot of sense for item groups to be hidden, as if they have no items, they will not be visible anyway, but if they do have items, it doesn't make sense to not display them.
That would make sense. It looks like the only way to hide this category is to either hide or mark nil every recipe and item within it. I assume "hidden" will cause fewer issues than "nil", so I'll use "hidden".

I can do this one item and recipe at a time. It would be tedious, but I'd only have to do it once.

As a general principle, I would like to know if there is some sort of wildcard feature I am missing.
User avatar
Osmo
Filter Inserter
Filter Inserter
Posts: 361
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: How do I remove something and everything that refers to it without having to do it all manually?

Post by Osmo »

000 wrote: Tue Sep 22, 2026 2:41 am I can do this one item and recipe at a time. It would be tedious, but I'd only have to do it once.

As a general principle, I would like to know if there is some sort of wildcard feature I am missing.
You can simply iterate over every recipe or item or any other prototypes, using something like this:

Code: Select all

for _, recipe in pairs(data.raw.recipe) do
  recipe.hidden = true
end

Code: Select all

for item_type, _ in pairs(defines.prototypes.item) do
  for _, item in pairs(data.raw[item_type]) do
    item.hidden = true
  end
end
Post Reply

Return to “Modding help”