Is it possible to have any item as input for a recipe?

Place to get help with not working mods / modding interface.
Post Reply
MegaHamster7
Inserter
Inserter
Posts: 21
Joined: Tue Oct 06, 2015 2:05 pm
Contact:

Is it possible to have any item as input for a recipe?

Post by MegaHamster7 »

I want to create a generic catch-all recipe for an incinerator mod I'm making.

The incinerator should be able to take any item in the game as an input and destroy it. However, I cannot find a way to allow any item in the game as an input. If I specify an input item then it works perfectly. I'd rather not have to go through every item in the game and add it to this mod to make it work. That would be tedious and more importantly limit mod support.

Here is my recipe:

Code: Select all

  {
    type = "recipe",
    name = "annihilate",
    category = "incineration",
    hidden = "true",
    energy_required = 1,
    ingredients =
    {
      {type="item", name="iron-plate", amount=1}
    },
    results =
    {
      {type="item", name="incinerated", amount=1, probability=0},
    },
    subgroup = "void",
    icon = "__incinerator__/graphics/icons/incinerated.png"
  }
At the moment you can see it's set up to work with iron plates. I tried "*" but that was wishful thinking... =)

Any ideas?

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by Adil »

Make a chest, that gets its inventory cleared up intermittently instead.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

MegaHamster7
Inserter
Inserter
Posts: 21
Joined: Tue Oct 06, 2015 2:05 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by MegaHamster7 »

I want to have something that is fueled like a smelter in order to delete items...

This also comes with the added bonus of producing pollution when it is working which is something I'm very keen on.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by DaveMcW »

You have to add a different recipe for every item in the game. Loop through data.raw.item in data-final-fixes.lua

MegaHamster7
Inserter
Inserter
Posts: 21
Joined: Tue Oct 06, 2015 2:05 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by MegaHamster7 »

Nice Dave, I was wondering if I could do something like that. How exactly do I do that? I'm new to LUA but not to coding so I'm just wondering where I run these commands to get a full list. Will this also pick up any mods I'm running?

Thank!

cartmen180
Filter Inserter
Filter Inserter
Posts: 358
Joined: Fri Jul 25, 2014 2:53 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by cartmen180 »

MegaHamster7 wrote:Nice Dave, I was wondering if I could do something like that. How exactly do I do that? I'm new to LUA but not to coding so I'm just wondering where I run these commands to get a full list. Will this also pick up any mods I'm running?

Thank!
That's why they added data-updates.lua and data-final-fixes.lua
I suggest to put those commands in the data-final-fixes as it is loaded last, to make sure to catch all the mod items.
Check out my mods

MegaHamster7
Inserter
Inserter
Posts: 21
Joined: Tue Oct 06, 2015 2:05 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by MegaHamster7 »

DaveMcW wrote:You have to add a different recipe for every item in the game. Loop through data.raw.item in data-final-fixes.lua
Where is this file? I can't seem to find it...

cartmen180
Filter Inserter
Filter Inserter
Posts: 358
Joined: Fri Jul 25, 2014 2:53 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by cartmen180 »

MegaHamster7 wrote:
DaveMcW wrote:You have to add a different recipe for every item in the game. Loop through data.raw.item in data-final-fixes.lua
Where is this file? I can't seem to find it...
Just create one in the main directory of your mod.
Check out my mods

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by bobingabout »

I sugest you take a look at reverse factory mod to see how they handle the dynamic recipe creation thing.

also don't forget to include the tag hidden=true on your created recipes, otherwise the number of them will overwhelm you/the player. you don't actually need to see the recipes of a furnace type factory anyway.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

MegaHamster7
Inserter
Inserter
Posts: 21
Joined: Tue Oct 06, 2015 2:05 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by MegaHamster7 »

bobingabout wrote:I sugest you take a look at reverse factory mod to see how they handle the dynamic recipe creation thing.

also don't forget to include the tag hidden=true on your created recipes, otherwise the number of them will overwhelm you/the player. you don't actually need to see the recipes of a furnace type factory anyway.
Cheers Bob, will have a look at that. Thanks for your void pump too which was a big help in creating what I have so far.

I've also started wondering if there's a way to vary the pollution based on the input too. I think that's one for when I've added these recipes but it would be pretty cool to have some things create more pollution.

napstrike
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Nov 13, 2015 9:12 pm
Contact:

Re: Is it possible to have any item as input for a recipe?

Post by napstrike »

Well you can make your incinirator to spawn two chests. In one chest you should put fuel, in the other chest you should put things that need to be incinirated. The code can check if there is fuel in the fuel chest, if there is, it should clear the items chest and delete 1 coal from the fuel chest. You can add an invisible furnace on top of your incinerator. Your code can clear that furnaces output slot, add 1 iron ore and 1 coal in that furnace whenever an inciniration occurs. This invisible furnace will be your pollution generator.

SO this is the logic:
1. Check if the fuel chest has coal
2. Remove 1 coal from the fuel chest
3. Clear the items chest
4. Clear the output slot of the invisible furnace
5. Add 1 Iron ore and 1 coal in the invisible furnace
6. wait 1 seconds
7. repeat

Post Reply

Return to “Modding help”