Is there an established way to 'remove' a prototype from the base game?

Place to get help with not working mods / modding interface.
User avatar
Fishbus
Long Handed Inserter
Long Handed Inserter
Posts: 52
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

Is there an established way to 'remove' a prototype from the base game?

Post by Fishbus »

Heya,

I'm trying to remove an item from the base game, so I can replace it with some other set of items without relying on overriding it.

Is there a way to remove an item from the base game when modding in a new one? For example, at some point I make:
data.raw["recipe"]["solid-fuel-from-petroleum-gas"] = nil
data.raw["item"]["solid-fuel-from-petroleum-gas"] = nil

removing this solid fuel recipe out.

I get an error:
Failed to load mods: Error in assignID: recipe with name 'solid-fuel-from-petroleum-gas' does not exist. It was removed by [modname].
Source: oil-processing (technology).


I tried to remove the entry in the base game technology to remove it:
table.removetablewithmatchingentry(data.raw["technology"]["oil-processing"].effects, "unlock-recipe", "solid-fuel-from-petroleum-gas")
(this is a helper function to find and remove entries that match and ultimately using the table.remove() function to do the dirty work )

It still throws up the error still. I tried the ordering of what is getting removed and when; but alas it still remains.

Is there a way out of this rabbit hole, or is it just better to have it exist and don't refer to it so it sits idle, or just override it completely?

Cheers!
User avatar
Fishbus
Long Handed Inserter
Long Handed Inserter
Posts: 52
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

Re: Is there an established way to 'remove' a prototype from the base game?

Post by Fishbus »

Ok, I just rubberducked myself.

I had an issue in the remove.table helper function where the reference isn't checked to see if it finds a valid match and throw an error if it doesn't exist.

:lol:

Still, the core of the question remains, is it fine to just up and "nil" stuff in the base game?
Pi-C
Smart Inserter
Smart Inserter
Posts: 1772
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Is there an established way to 'remove' a prototype from the base game?

Post by Pi-C »

You should never remove prototypes! If you do that, it's quite likely that you'll break things for other mods. What you can do is hide prototypes of entities, items etc., the recipes that make them, and unlocks in technologies. This way, other mods can still use the prototype to create their own stuff (table.deepcopy(), modify, data:extend()) – but players won't be able to make new items/entities based on the hidden prototypes unless they use a cheat.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
Fishbus
Long Handed Inserter
Long Handed Inserter
Posts: 52
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

Re: Is there an established way to 'remove' a prototype from the base game?

Post by Fishbus »

Right, keep the older protoypes and throw a hidden = true on them.

Cheers 8-)
Pi-C
Smart Inserter
Smart Inserter
Posts: 1772
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Is there an established way to 'remove' a prototype from the base game?

Post by Pi-C »

You may also want to add hidden_in_factoriopedia= true!
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Modding help”