Page 1 of 1

How do i make a recipe use a fluid/output a fluid?

Posted: Mon Apr 01, 2019 6:02 am
by Techfish3000
Just wondering if it is just as easy as something like this

Code: Select all

concreterecipe = {

type = "recipe",
name = "water-sediment",
ingredients =
   {
    {"water", 50}
   },
result = {"refined-concrete", 10}
energy_required = 5
}
or if it needs something extra.
thanks in advance!

Re: How do i make a recipe use a fluid/output a fluid?

Posted: Tue Apr 02, 2019 9:25 am
by bobingabout
there are 2 methods for defining ingredients in a recipe.
the first one is the short method, which you've used there.

Code: Select all

{"item-name", amount}
however, as you can see, it wants an ITEM name, fluids aren't items.
There's a longer method as follows

Code: Select all

{type = "item", name = "item-name", amount = amount}
Type can be changed, your example would be:

Code: Select all

{type = "fluid", name = "water", amount = 50}
Ingredients, and results use the simple item type method, so the only valid types are item and fluid. so definitions such as type "tool" that you need to use to define items like science packs just come under the type "item" when used by a recipe.

Result (output) is different too. the result= tag is result="item-name", again, assumed item, also assumed amount is only 1. You can change the amount using result_count = 10 as an example, and then you'd get 10 of that item instead of just 1. so again, your example:

Code: Select all

result = "refined-concrete", 
result_count = 10,
however, this works for items, but not fluids. if you want a fluid, you'll need to use the complex results = tag instead.

Code: Select all

results =
{
  {type = "fluid", name = "crude-oil", amount = 50}
}
results can have additional entries on it, such as amount_min and amount_max, where a random amount between the 2 values is used. or probability = 0.5, the item will only appear 50% of the time.
you CAN use this method to define entries with more than 1 result, however, this will error. you need to define a few extra things like... icon, icon_size, order, etc, that you normally define on an item. you'll also need to define a locale entry for the recipe, as by default that too is taken from the item. when you use a single result, these are taken from the item definition.

I think if you can also use main_product = "item-name", then any of the mentioned data you require is taken from the item listed on this tag instead of having to be defined.
For more examples, take a look at the fluid-recipe.lua file in the base game, Oil processing uses this extended recipe system a lot.

Re: How do i make a recipe use a fluid/output a fluid?

Posted: Tue Apr 02, 2019 10:17 am
by darkfrei
But results is a table with array of tables:

Code: Select all

results = {
    {type = "fluid", name = "crude-oil", amount = 50}
  }
Or it can be used for items:

Code: Select all

results = {
    {type = "item", name = "refined-concrete", amount = 10}
  }
This format works, but makes crashing some mods:

Code: Select all

results = {
    {"refined-concrete", 10}
  }

Re: How do i make a recipe use a fluid/output a fluid?

Posted: Tue Apr 02, 2019 12:53 pm
by Techfish3000
darkfrei wrote:
Tue Apr 02, 2019 10:17 am

This format works, but makes crashing some mods:

Code: Select all

results = {
    {"refined-concrete", 10}
  }
That's what i used after a bit of messing around in the API. Will have to try the other methods as well!

Also, didn't expect the legendary bobingabout himself to reply, You make great mods!

Also Also, I have a work-in-progress mod called "BeltArmour" in the making, it will be my first published mod, maybe you can help me crash test it?

Also Also Also, the code I described is for another mod idea I had, but is kinda a scrapped idea. Thanks anyway!