Item added by mod has unexpected "Yield" property in UI
Posted: Tue Oct 29, 2024 10:53 am
For training purposes, I just created a simple mod that adds a new lamp recipe, item, and entity with modified energy requirements.
All added prototypes are exact deep copies of the original small-lamp. Everything works as expected, only:
My modded item, when crafted, shows an additional "Yield" attribute in the inventory UI on mouse over, however the original small-lamp doesn't show "Yield" in the UI.
I even logged the item prototype (both the original and my cloned and modified one) using serpent to compare them. I can't really see any differences apart from the expected ones, like place_result and name. The modding API docs also don't show a dedicated yield property at the code level, so it must come from something else in the UI.
The only idea I have left is that I'm cloning the wrong base prototype for the lamp, maybe? I used table.deepcopy on data.raw["item"]["small-lamp"] - is this maybe the wrong item?
This is my specific code:
If it helps, here's the recipe and entity as well:
Can someone who's experienced with modding factorio give me a pointer on where this "Yield" property is coming from? My thinking is: I just cloned the item, which doesn't have "Yield". So why would my clone suddenly have it?
Thanks in advance!
All added prototypes are exact deep copies of the original small-lamp. Everything works as expected, only:
My modded item, when crafted, shows an additional "Yield" attribute in the inventory UI on mouse over, however the original small-lamp doesn't show "Yield" in the UI.
I even logged the item prototype (both the original and my cloned and modified one) using serpent to compare them. I can't really see any differences apart from the expected ones, like place_result and name. The modding API docs also don't show a dedicated yield property at the code level, so it must come from something else in the UI.
The only idea I have left is that I'm cloning the wrong base prototype for the lamp, maybe? I used table.deepcopy on data.raw["item"]["small-lamp"] - is this maybe the wrong item?
This is my specific code:
Code: Select all
local prototype = table.deepcopy(data.raw['item']['small-lamp'])
prototype.name = "solar-appliances-solar-lamp-item"
prototype.place_result = "solar-appliances-solar-lamp-entity"
log(serpent.block(prototype))
log(serpent.block(data.raw['item']['small-lamp']))
data: extend({prototype})
Code: Select all
local prototype = table.deepcopy(data.raw['recipe']['small-lamp'])
prototype.name = "solar-appliances-solar-lamp-recipe"
prototype.localised_name = { "recipe-name.solar-appliances-solar-lamp" }
prototype.enabled = true
prototype.results = {
{ type = "item", name = "solar-appliances-solar-lamp-item", amount = 1 },
}
prototype.main_product = nil
prototype.result_count = nil
table.insert(prototype.ingredients, { type = "item", name = "solar-panel", amount = 1 })
table.insert(prototype.ingredients, { type = "item", name = "battery", amount = 2 })
log(serpent.block(prototype))
log(serpent.block(data.raw['recipe']['small-lamp']))
data:extend({ prototype })
Code: Select all
local prototype = table.deepcopy(data.raw['lamp']['small-lamp'])
prototype.name = "solar-appliances-solar-lamp-entity"
prototype.energy_source = { type = "void" }
prototype.localised_name = { "entity-name.solar-appliances-solar-lamp" }
if prototype.minable then
prototype.minable.result = "solar-appliances-solar-lamp-item"
end
log(serpent.block(prototype))
log(serpent.block(data.raw['lamp']['small-lamp']))
data:extend({ prototype })
Thanks in advance!