Page 1 of 1
RecipePrototype results and main_product expected values?
Posted: Tue Oct 29, 2024 8:35 am
by firebladed3
with
RecipePrototype what are the "normal" expected values?
Im unsure if this is normal or a bug but when i read the RecipePrototype for "burner-lab"
[Edit] i get LuaRecipePrototype doesn't contain key results.
and
recipe.main_product as a
ItemProductPrototype?
Code: Select all
{
amount = 1,
name = "burner-lab",
probability = 1,
type = "item"
}
This seems odd to me from the descriptions of those in RecipePrototype Docs
results optional :: array[ProductPrototype] A table containing result names and amounts. [...]
main_product optional :: string For recipes with one or more products: Subgroup, localised_name and icon default to the values of the singular/main product, but can be overwritten by the recipe. [...]
Im thinking that either the description of main_product is lacking or there is something odd here
anyone more familar with this have any input?
Re: RecipePrototype results and main_product expected values?
Posted: Tue Oct 29, 2024 8:43 am
by Stringweasel
If a recipe has any products, then it needs to be in the recipe.results table. If a main_product is defined without products in results then it should fail to load.
I think the example code you're looking at is wrong. Where are you getting the prototype for `burner-lab`?
Re: RecipePrototype results and main_product expected values?
Posted: Tue Oct 29, 2024 9:16 am
by firebladed3
im getting from prototypes.get_recipe_filtered(filters)
but the result from prototypes.recipe['burner-lab'] is the same error
Both are "[LuaRecipePrototype: burner-lab (recipe)]"
and both error with "LuaRecipePrototype doesn't contain key results"
im testing with
Code: Select all
log(serpent.block(prototypes.recipe['burner-lab'].results))
and
Code: Select all
log(serpent.block(recipe.results))
for the recipe returned from prototypes.get_recipe_filtered(filters)
im going to look at some other recipes
Edit: im getting this error consistently even from LUA Console from multiple items
e.g
Code: Select all
prototypes.recipe['burner-mining-drill'].results
Re: RecipePrototype results and main_product expected values?
Posted: Tue Oct 29, 2024 9:36 am
by Stringweasel
Ah, I think I see the problem. You're mixing data-stage with runtime stage. Look at the
LifeCycle. During data-stage `results` must exist, just like in the link you originally mentioned. But you're doing the `log` during the runtime (control) stage, where you're interacting with a
LuaRecipePrototype, and it has `products` instead of `results`.
If you want the products during control stage you need something like this
Code: Select all
log(serpent.block(prototypes.recipe['burner-lab'].products))
And for reference, assuming the burner-lab you're looking at is from AAI Industries, this is how that recipe is defined in data stage:
Code: Select all
{
type = "recipe",
name = "burner-lab",
category = "crafting",
enabled = true,
energy_required = 0.5,
ingredients =
{
{type="item", name="motor", amount=10},
{type="item", name="copper-plate", amount=10},
{type="item", name="stone-brick", amount=5}
},
results= { {type="item", name="burner-lab", amount=1} }
Re: RecipePrototype results and main_product expected values?
Posted: Tue Oct 29, 2024 9:52 am
by firebladed3
Ok
on further examination there is an inconsistency between
https://lua-api.factorio.com/latest/prototypes/RecipePrototype.html
and
https://lua-api.factorio.com/latest/classes/LuaRecipePrototype.html
the first has results and the second has products
which is somewhat confusing
Edit:
thx, somehow missed post when writing
Im writing code for the control stage, but it seems I incorrectly made the assumption that the classes would mirror the data tables and just searched in the window i had open
the 'burner-lab' is coincidental it just happend to be what the filter produced