Page 1 of 1
Is it possible to have any item as input for a recipe?
Posted: Wed Oct 14, 2015 4:59 pm
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?
Re: Is it possible to have any item as input for a recipe?
Posted: Wed Oct 14, 2015 5:12 pm
by Adil
Make a chest, that gets its inventory cleared up intermittently instead.
Re: Is it possible to have any item as input for a recipe?
Posted: Wed Oct 14, 2015 5:29 pm
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.
Re: Is it possible to have any item as input for a recipe?
Posted: Thu Oct 15, 2015 7:49 am
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
Re: Is it possible to have any item as input for a recipe?
Posted: Thu Oct 15, 2015 10:00 pm
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!
Re: Is it possible to have any item as input for a recipe?
Posted: Thu Oct 15, 2015 10:16 pm
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.
Re: Is it possible to have any item as input for a recipe?
Posted: Fri Oct 16, 2015 1:38 pm
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...
Re: Is it possible to have any item as input for a recipe?
Posted: Fri Oct 16, 2015 1:48 pm
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.
Re: Is it possible to have any item as input for a recipe?
Posted: Mon Oct 19, 2015 9:26 am
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.
Re: Is it possible to have any item as input for a recipe?
Posted: Tue Oct 20, 2015 4:52 pm
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.
Re: Is it possible to have any item as input for a recipe?
Posted: Sat Nov 14, 2015 1:35 am
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