control.lua:
Code: Select all
local function player_setup_blueprint(event)
log("player_setup_blueprint")
local player = game.players[event.player_index]
local bp = player.blueprint_to_setup
if not bp or not bp.valid_for_read then
bp = player.cursor_stack
end
if not bp or not bp.valid_for_read then
return
end
local entities = bp.get_blueprint_entities()
if not entities then
return
end
for i, entity in ipairs(entities) do
if entity.name == "tag-chest" then
log("adding tag to tag-chest")
bp.set_blueprint_entity_tag(i, "example-tag", entity.unit_number)
log("example-tag = " .. serpent.block(bp.get_blueprint_entity_tag(i, "example-tag")))
end
end
end
Code: Select all
local tag_chest = table.deepcopy(data.raw["container"]["wooden-chest"])
tag_chest.name = "tag-chest"
tag_chest.minable = {mining_time = 1, result = "tag-chest"}
data:extend {
{
type = "item-with-tags",
name = "tag-chest",
icon = "__base__/graphics/icons/wooden-chest.png",
icon_size = 32,
flags = {},
subgroup = "other",
order = "s[item-with-tags]-o[item-with-tags]",
stack_size = 1,
place_result = "tag-chest",
},
tag_chest,
{
type = "recipe",
name = "tag-chest",
ingredients = {},
result = "tag-chest"
},
}