Page 1 of 1

Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Thu Sep 12, 2019 6:01 pm
by Therenas
Currently, during the control stage, the catalyst_amount attribute is available on ingredients and products of LuaRecipe, but not of LuaRecipePrototype. I suggest adding that attribute to the prototype too, to make it consistent for one and because it doesn't change during runtime, so it should probably be part of the prototype definition. It makes modders not have to reach into the LuaRecipe when they have the prototype right there.

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Thu Oct 10, 2019 10:24 am
by PyroFire
This appears to be a thing already ?

https://lua-api.factorio.com/latest/Lua ... ngredients

https://lua-api.factorio.com/latest/Lua ... ngredients

https://lua-api.factorio.com/latest/Con ... Ingredient

Unless you are saying the api shows this value *should* be in the ingredients table but is actually bugged and the value isn't there?

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Thu Oct 10, 2019 10:34 am
by Therenas
That's the LuaRecipe, not the LuaRecipePrototype. I want it on the prototype so I can access it without having to associate it with a player, which can be inconvenient/impossible at times. As the value doesn't change at runtime, I don't see why it shouldn't be accessible on the prototype as well.

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Thu Oct 10, 2019 10:47 am
by Klonan
Therenas wrote:
Thu Oct 10, 2019 10:34 am
That's the LuaRecipe, not the LuaRecipePrototype. I want it on the prototype so I can access it without having to associate it with a player, which can be inconvenient/impossible at times. As the value doesn't change at runtime, I don't see why it shouldn't be accessible on the prototype as well.
It is accessible on the prototype:
https://lua-api.factorio.com/latest/Lua ... ngredients

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Thu Oct 10, 2019 10:57 am
by Therenas
It's not in reality though (The first log is the LuaRecipePrototype, the second is the LuaRecipe):

Code: Select all

6103.263 Script @__factoryplanner__/data/util.lua:236: {
  {
    amount = 5,
    name = "uranium-238",
    type = "item"
  },
  {
    amount = 40,
    name = "uranium-235",
    type = "item"
  }
}
6103.264 Script @__factoryplanner__/data/util.lua:241: {
  {
    amount = 5,
    catalyst_amount = 2,
    name = "uranium-238",
    type = "item"
  },
  {
    amount = 40,
    catalyst_amount = 40,
    name = "uranium-235",
    type = "item"
  }
}
So it might even be a bug then?

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Thu Oct 10, 2019 1:15 pm
by Klonan
So its some special logic, that the recipe will set up itself to auto detect catalysts

So kovarex enrichment doesn't actually specify any catalyst amount,
Just when the recipe is 'setup', the game auto detects the catalysts.

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Mon Oct 14, 2019 1:38 pm
by Honktown
If I recall correctly, if an item is both an ingredient and output product, logic was added to not apply certain things like productivity to that ingredient (explicitly for the case of kovarex enrichment). Is there a way to make a hidden output inventory for a catalyst, fully consume the catalyst, and still have the logic trigger?

In addition, there are mods that use different output recipes automatically, besides the smelter itself in vanilla. Reverse Factory is the first one I can think of. If a machine could auto-detect multiple ingredients, and if the recipe matched the most complex recipe first (say it checked catalyst slot before checking the first) one could have a smelter which took an optional catalyst and output more as a result, by auto-switching recipes when the catalyst is present.

These are workarounds, as there is no catalyst = , catalyst_result = , and/or the plural+tables, which might be the best case of what you're going for.

I always wondered why we needed no carbon to convert iron to steel (maybe a catalyst_ingredients could be added, but that adds a bit more complexity). Perhaps a catalyst_effects would be the easiest way to implement all of these things, so you can multiply the output products, alter the crafting speed, etc. Kovarex could be changed to be a painfully slow process without the catalyst, and sped up and double the output products with it (3 lousy uranium to one good takes 10 minutes, or 2 minutes and 2 good). Steel could be made slowly by itself, or using "refined carbon" e.g. smelt coal and stuff that in the furnace. Most mod recipes could use the catalyst to add a multiplier to output product, or even have the option to change it entirely. Non-consumable catalysts would have their uses, too.

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Sat Oct 26, 2019 7:45 am
by Erythion
I just found out that this issue existed, and thankfully got pointed to this thread. It does seem wasteful to not have the catalyst data in LuaRecipePrototype.

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Mon Oct 28, 2019 6:23 pm
by Rseding91
It's now changed for the next version of 0.17 thanks to Boodals.

Re: Add catalyst_amount to LuaRecipePrototype ingredients/products

Posted: Mon Oct 28, 2019 10:48 pm
by Therenas
Great news, thanks to you and thanks again to Boodals.