While working on an upcoming mod, I was experimenting with simple toy recipe and item prototypes for a 'crude metal furnace', which is crafted using metal plate, but places a stone furnace when built ( place_result = "stone-furnace" ) (full details below)
I then tested out the prototype in-game and noticed some odd behavior
What happened?
The new Crude Metal Furnace item worked as expected - I can place it in all circumstances. However, I ran into an issue with the original Stone Furnace item - it could only be placed if my player's inventory contained at least one Crude Metal Furnace item. Placing the Stone Furnace item didn't consume a Crude Metal Furnace item, but I had to have at least one Crude Metal Furnace in my inventory otherwise I'd get a flying text message "Missing Crude Metal Furnace".
What did you expect to happen instead? It might be obvious to you, but do it anyway!
I expected to be able to hand-place a Stone Furnace item regardless of whether I had any Crude Metal Furnace items in my inventory or not
Does it happen always, once, or sometimes?
It happens all the time under the circumstances described above. I did try a couple of changes suggested by Discord chat #mod-dev-help, but to no avail:
- I tried manually setting the "placeable_by" property on the "stone-furnace" entity prototype, but this didn't change anything and using "/c" commands in game, it seems like the setting didn't go through anyways
- I tried manually adding the "primary-place-result" flag to the "stone-furnace" item prototype. This fixed things for the stone-furnace item, but then the crude-metal-furnace item started having the issue instead - i.e. it would fail to place unless I also had a "stone-furnace" item in my inventory.
Prototype code (data.lua):
Code: Select all
local crudeMetalFurnaceItem = {
-- Copied from stone-furnace
type = "item",
name = "crude-metal-furnace",
icon = "__base__/graphics/icons/stone-furnace.png",
localised_name = "Crude Metal Furnace",
localised_description = "A crude furnace crafted from metal, equivalent to a Stone Furnace",
subgroup = "smelting-machine",
order = "a[crude-metal-furnace]",
inventory_move_sound = {filename="__base__/sound/item/metal-small-inventory-move.ogg", volume=0.8},
pick_sound = {filename="__base__/sound/item/metal-small-inventory-pickup.ogg", volume=0.8},
drop_sound = {filename="__base__/sound/item/metal-small-inventory-move.ogg", volume=0.8},
place_result = "stone-furnace",
stack_size = 50
}
local copperFurnaceRecipe = {
type = "recipe",
localised_name = "Crude Copper Furnace",
localised_description = "Craft a crude furnace using iron plate",
name = "copper-furnace",
ingredients = {{type="item", name="copper-plate", amount=2}},
results = {{type="item", name="crude-metal-furnace", amount=1}}
}
local ironFurnaceRecipe = {
type = "recipe",
name = "iron-furnace",
localised_name = "Crude Iron Furnace",
localised_description = "Craft a crude furnace using copper plate",
ingredients = {{type="item", name="iron-plate", amount=2}},
results = {{type="item", name="crude-metal-furnace", amount=1}}
}
data:extend {
crudeMetalFurnaceItem, copperFurnaceRecipe, ironFurnaceRecipe
}
-- Failed attempt to fix things using ItemPrototypeFlags
local itemStoneFurnace = data.raw["item"]["stone-furnace"]
itemStoneFurnace.flags = itemStoneFurnace.flags or {}
table.insert(itemStoneFurnace.flags, "primary-place-result")
-- Failed attempt to fix things using EntityPrototype.placeable_by
local entityStoneFurnace = data.raw["furnace"]["stone-furnace"]
entityStoneFurnace.placeable_by = {item="stone-furnace", count=1}
