[2.0.9] Weird issue trying to place entities with multiple items defined

Things that has been reported already before.
ceresward
Inserter
Inserter
Posts: 26
Joined: Mon Dec 18, 2017 8:45 pm
Contact:

[2.0.9] Weird issue trying to place entities with multiple items defined

Post by ceresward »

What did you do?

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:
  1. 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
  2. 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}
Screenshot:

Image
Attachments
factorio-current.log
(8.24 KiB) Downloaded 18 times
ceresward
Inserter
Inserter
Posts: 26
Joined: Mon Dec 18, 2017 8:45 pm
Contact:

Re: [2.0.9] Weird issue trying to place entities with multiple items defined

Post by ceresward »

I should also make clear - I'm aware I could just have the new recipes create a Stone Furnace item instead of having their own item prototype, but the whole reason I was experimenting with this was because I wanted some easy way to test the actual mod logic in a scenario where there are multiple items that share the same entity as their place_result. I imagine there are likely more realistic scenarios where this could actually happen, this was just the easiest way for me to test it.
ceresward
Inserter
Inserter
Posts: 26
Joined: Mon Dec 18, 2017 8:45 pm
Contact:

Re: [2.0.9] Weird issue trying to place entities with multiple items defined

Post by ceresward »

I can confirm 2.0.11 fixes the issue for me too. Thanks!
Post Reply

Return to “Duplicates”