Is there a way to have the blueprint tool to look at the generated entity as its placeholder? (WANTED-ENTITY looks like PLACEHOLDER-ENTITY to the blueprint tool and gets stored in the blueprint as such)
the code is as follow:
IN CONTROL.LUA
Code: Select all
placeholder_table =
{
["ENTITY-PLACEHOLDER"] = "WANTED-ENTITY",
}
[...]
local placeholder = event.created_entity or event.entity
local placeholder_name = placeholder.name
local surface = placeholder.surface
local position = placeholder.position
local direction = placeholder.direction
local force = placeholder.force
local name = placeholder_table[placeholder_name]
if not name then return else end
placeholder.destroy() --destroys "ENTITY-PLACEHOLDER"
surface.create_entity --replaces it with "WANTED-ENTITY"
{
name = name,
position = position,
direction = direction,
force = force,
fast_replace = true,
spill = false,
raise_built = true,
create_build_effect_smoke = false
}
[...]
Code: Select all
RECIPE
[...]
result = "ENTITY" --item name
[...]
ITEM:
[...]
name = "ENTITY" -- item name
place_result = "ENTITY-PLACEHOLDER", --entity placed
[...]
ENTITY-PLACEHOLDER: -- note that if this entity is placed down with /editor it is indeed blueprintable
[...]
name = "ENTITY-PLACEHOLDER"
minable = {mining_time = 0.1, result = "ENTITY"} --item name
[...]
WANTED-ENTITY:
[...]
name = "WANTED-ENTITY"
minable = {mining_time = 0.1, result = "ENTITY"} --drops the above "ITEM"
placeable_by = {item = "ENTITY", count = 1} --placed by the above "ITEM"
[...]