After several sloppy edits, I can now place my new electrical pole down then the lamp and roboport addons will spawn into place. If I pick up the pole, the addons are removed as intended. Only issue I have left is that my new logistic addon isn't connecting to my existing network. If I place it down directly it will connect to the network but not to the script spawned entities. The script spawned addons WILL connect to each other.
I've obviously done something incorrectly but as I've never played around with complicated on_event scripts, I haven't got a clue what I did wrong. And even less of a clue on where to start looking.
sloppy update of control.lua from factorio v12
control
backbone.lua
-- Factory backbone control set
function BuiltEntity(event)
-- spawn light addon
if event.created_entity.name == "factory-backbone" then
local e = event.created_entity
local s = e.surface
local X = e.position.x
local Y = e.position.y
local l = s.create_entity{name = "backbone-light", position = {X,Y}, force= game.forces.neutral}
l.destructible = false
end
-- spawn logistic addon
if event.created_entity.name == "factory-backbone" then
local e = event.created_entity
local s = e.surface
local X = e.position.x
local Y = e.position.y
local l = s.create_entity{name = "backbone-logistics", position = {X,Y}, force= game.forces.neutral}
l.destructible = false
end
end
-- remove light addon
function MinedEntity(event)
if event.entity.name == "factory-backbone" then
local b = event.entity
local X = b.position.x
local Y = b.position.y
lamp = b.surface.find_entities_filtered{area = {{X -0.5, Y - 0.5 }, {X + 0.5 , Y +0.5 }}, name= "backbone-light"}
if lamp[1] ~= nil then
lamp[1].destroy() end
end
-- remove logistic addon
if event.entity.name == "factory-backbone" then
local b = event.entity
local X = b.position.x
local Y = b.position.y
roboport = b.surface.find_entities_filtered{area = {{X -0.5, Y - 0.5 }, {X + 0.5 , Y +0.5 }}, name= "backbone-logistics"}
if roboport[1] ~= nil then
roboport[1].destroy() end
end
end
script.on_event(defines.events.on_built_entity, BuiltEntity)
script.on_event(defines.events.on_robot_built_entity, BuiltEntity)
script.on_event(defines.events.on_preplayer_mined_item , MinedEntity)
script.on_event(defines.events.on_entity_died , MinedEntity)
script.on_event(defines.events.on_robot_pre_mined , MinedEntity)
function BuiltEntity(event)
-- spawn light addon
if event.created_entity.name == "factory-backbone" then
local e = event.created_entity
local s = e.surface
local X = e.position.x
local Y = e.position.y
local l = s.create_entity{name = "backbone-light", position = {X,Y}, force= game.forces.neutral}
l.destructible = false
end
-- spawn logistic addon
if event.created_entity.name == "factory-backbone" then
local e = event.created_entity
local s = e.surface
local X = e.position.x
local Y = e.position.y
local l = s.create_entity{name = "backbone-logistics", position = {X,Y}, force= game.forces.neutral}
l.destructible = false
end
end
-- remove light addon
function MinedEntity(event)
if event.entity.name == "factory-backbone" then
local b = event.entity
local X = b.position.x
local Y = b.position.y
lamp = b.surface.find_entities_filtered{area = {{X -0.5, Y - 0.5 }, {X + 0.5 , Y +0.5 }}, name= "backbone-light"}
if lamp[1] ~= nil then
lamp[1].destroy() end
end
-- remove logistic addon
if event.entity.name == "factory-backbone" then
local b = event.entity
local X = b.position.x
local Y = b.position.y
roboport = b.surface.find_entities_filtered{area = {{X -0.5, Y - 0.5 }, {X + 0.5 , Y +0.5 }}, name= "backbone-logistics"}
if roboport[1] ~= nil then
roboport[1].destroy() end
end
end
script.on_event(defines.events.on_built_entity, BuiltEntity)
script.on_event(defines.events.on_robot_built_entity, BuiltEntity)
script.on_event(defines.events.on_preplayer_mined_item , MinedEntity)
script.on_event(defines.events.on_entity_died , MinedEntity)
script.on_event(defines.events.on_robot_pre_mined , MinedEntity)
backbone
-- Factory Backbone Test
data:extend(
{
{
type = "recipe",
name = "factory-backbone",
enabled = "true",
energy_required = 15,
ingredients =
{
{"processing-unit", 20},
{"steel-plate", 150},
{"small-lamp", 5}
},
result = "factory-backbone",
icon = "__anarchy__/graphics/icons/backbone-icon.png"
},
}
)
data:extend(
{
{
type = "item",
name = "factory-backbone",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"goes-to-quickbar"},
subgroup = "energy-pipe-distribution",
order = "a[energy]-e[factory-backbone]",
place_result = "factory-backbone",
stack_size = 50
},
{
type = "item",
name = "backbone-light",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"hidden"},
subgroup = "energy",
order = "a[energy]-e[factory-backbone]",
place_result = "backbone-light",
stack_size = 50
},
{
type = "item",
name = "backbone-logistics",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"hidden"},
subgroup = "energy",
order = "a[energy]-e[factory-backbone]",
place_result = "backbone-logistics",
stack_size = 50
}
}
)
data:extend(
{
{
type = "electric-pole",
name = "factory-backbone",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"placeable-neutral", "player-creation"},
minable = {hardness = 0.2, mining_time = 1.5, result = "factory-backbone"},
max_health = 350,
corpse = "small-remnants",
collision_box = {{-0.05, -0.05}, {0.05, 0.05}},
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
drawing_box = {{-0.5, -2.6}, {0.5, 0.5}},
maximum_wire_distance = 36.5,
supply_area_distance = 18.5,
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 1.0 },
pictures =
{
filename = "__anarchy__/graphics/entity/backbone.png",
priority = "extra-high",
width = 136,
height = 132,
axially_symmetrical = false,
direction_count = 1,
shift = {1, -0.75},
},
connection_points =
{
{
shadow =
{
copper = {2.60, -0.6},
green = {2.55, -0.6},
red = {2.65, -0.6}
},
wire =
{
copper = {0.25, -2.65},
green = {0.30,-2.65},
red = {0.35,-2.65}
}
},
},
radius_visualisation_picture =
{
filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png",
width = 16,
height = 16
}
},
{
type = "lamp",
name = "backbone-light",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"placeable-neutral","placeable-off-grid", "player-creation"},
minable = {hardness = 0.2, mining_time = 1.5},
max_health = 350,
corpse = "small-remnants",
collision_box = {{0, 0}, {0, 0}},
selection_box = {{0, 0}, {0, 0}},
energy_source =
{
type = "electric",
usage_priority = "secondary-input"
},
energy_usage_per_tick = "50KW",
light = {intensity = 0.9, size = 100},
light_when_colored = {intensity = 1, size = 6},
glow_size = 6,
glow_color_intensity = 0.135,
picture_off =
{
filename = "__anarchy__/graphics/entity/blank.png",
priority = "medium",
width = 1,
height = 1,
axially_symmetrical = false,
direction_count = 1,
-- shift = {1, -0.75},
},
picture_on =
{
filename = "__anarchy__/graphics/entity/backbonelighton.png",
priority = "high",
width = 136,
height = 132,
frame_count = 1,
axially_symmetrical = false,
direction_count = 1,
shift = {1, -0.75},
},
signal_to_color_mapping =
{
{signal="signal-red", color={r=1,g=0,b=0}},
{signal="signal-green", color={r=0,g=1,b=0}},
{signal="signal-blue", color={r=0,g=0,b=1}},
{signal="signal-yellow", color={r=1,g=1,b=0}},
{signal="signal-pink", color={r=1,g=0,b=1}},
{signal="signal-cyan", color={r=0,g=1,b=1}},
},
circuit_wire_connection_point =
{
shadow =
{
red = {0.734375, 0.578125},
green = {0.609375, 0.640625},
},
wire =
{
red = {0.40625, 0.34375},
green = {0.40625, 0.5},
}
},
circuit_connector_sprites = get_circuit_connector_sprites({0.1875, 0.28125}, {0.1875, 0.28125}, 18),
circuit_wire_max_distance = 36.5
},
{
type = "roboport",
name = "backbone-logistics",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"placeable-neutral", "placeable-off-grid", "player-creation"},
minable = {hardness = 0.2, mining_time = 1.5},
max_health = 350,
corpse = "small-remnants",
collision_box = {{0, 0}, {0, 0}},
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
logistics_radius = 18.5,
construction_radius = 36.5,
energy_source =
{
type = "electric",
usage_priority = "secondary-input",
input_flow_limit = "5MW",
buffer_capacity = "100MJ"
},
recharge_minimum = "5MJ",
energy_usage = "50KW",
charging_energy = "5MW",
robot_slots_count = 0,
material_slots_count = 0,
charge_approach_distance = 5,
charging_offsets =
{
{-1.5, -0.5}, {1.5, -0.5}, {1.5, 1.5}, {-1.5, 1.5},
},
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 1.0 },
base =
{
filename = "__anarchy__/graphics/entity/backbone.png",
width = 136,
height = 132,
shift = {1, -0.75}
},
base_animation =
{
filename = "__anarchy__/graphics/entity/blank.png",
priority = "medium",
width = 1,
height = 1,
frame_count = 1
},
base_patch =
{
filename = "__anarchy__/graphics/entity/blank.png",
width = 1,
height = 1,
frame_count = 1
},
door_animation_up =
{
filename = "__anarchy__/graphics/entity/blank.png",
width = 1,
height = 1,
frame_count = 1
},
door_animation_down =
{
filename = "__anarchy__/graphics/entity/blank.png",
width = 1,
height = 1,
frame_count = 1
},
recharging_animation =
{
filename = "__anarchy__/graphics/entity/blank.png",
width = 1,
height = 1,
frame_count = 1
},
recharging_light = {intensity = 0.4, size = 5},
request_to_open_door_timeout = 15,
spawn_and_station_height = 1.75,
draw_logistic_radius_visualization = true,
draw_construction_radius_visualization = true,
}
}
)
data:extend(
{
{
type = "recipe",
name = "factory-backbone",
enabled = "true",
energy_required = 15,
ingredients =
{
{"processing-unit", 20},
{"steel-plate", 150},
{"small-lamp", 5}
},
result = "factory-backbone",
icon = "__anarchy__/graphics/icons/backbone-icon.png"
},
}
)
data:extend(
{
{
type = "item",
name = "factory-backbone",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"goes-to-quickbar"},
subgroup = "energy-pipe-distribution",
order = "a[energy]-e[factory-backbone]",
place_result = "factory-backbone",
stack_size = 50
},
{
type = "item",
name = "backbone-light",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"hidden"},
subgroup = "energy",
order = "a[energy]-e[factory-backbone]",
place_result = "backbone-light",
stack_size = 50
},
{
type = "item",
name = "backbone-logistics",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"hidden"},
subgroup = "energy",
order = "a[energy]-e[factory-backbone]",
place_result = "backbone-logistics",
stack_size = 50
}
}
)
data:extend(
{
{
type = "electric-pole",
name = "factory-backbone",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"placeable-neutral", "player-creation"},
minable = {hardness = 0.2, mining_time = 1.5, result = "factory-backbone"},
max_health = 350,
corpse = "small-remnants",
collision_box = {{-0.05, -0.05}, {0.05, 0.05}},
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
drawing_box = {{-0.5, -2.6}, {0.5, 0.5}},
maximum_wire_distance = 36.5,
supply_area_distance = 18.5,
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 1.0 },
pictures =
{
filename = "__anarchy__/graphics/entity/backbone.png",
priority = "extra-high",
width = 136,
height = 132,
axially_symmetrical = false,
direction_count = 1,
shift = {1, -0.75},
},
connection_points =
{
{
shadow =
{
copper = {2.60, -0.6},
green = {2.55, -0.6},
red = {2.65, -0.6}
},
wire =
{
copper = {0.25, -2.65},
green = {0.30,-2.65},
red = {0.35,-2.65}
}
},
},
radius_visualisation_picture =
{
filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png",
width = 16,
height = 16
}
},
{
type = "lamp",
name = "backbone-light",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"placeable-neutral","placeable-off-grid", "player-creation"},
minable = {hardness = 0.2, mining_time = 1.5},
max_health = 350,
corpse = "small-remnants",
collision_box = {{0, 0}, {0, 0}},
selection_box = {{0, 0}, {0, 0}},
energy_source =
{
type = "electric",
usage_priority = "secondary-input"
},
energy_usage_per_tick = "50KW",
light = {intensity = 0.9, size = 100},
light_when_colored = {intensity = 1, size = 6},
glow_size = 6,
glow_color_intensity = 0.135,
picture_off =
{
filename = "__anarchy__/graphics/entity/blank.png",
priority = "medium",
width = 1,
height = 1,
axially_symmetrical = false,
direction_count = 1,
-- shift = {1, -0.75},
},
picture_on =
{
filename = "__anarchy__/graphics/entity/backbonelighton.png",
priority = "high",
width = 136,
height = 132,
frame_count = 1,
axially_symmetrical = false,
direction_count = 1,
shift = {1, -0.75},
},
signal_to_color_mapping =
{
{signal="signal-red", color={r=1,g=0,b=0}},
{signal="signal-green", color={r=0,g=1,b=0}},
{signal="signal-blue", color={r=0,g=0,b=1}},
{signal="signal-yellow", color={r=1,g=1,b=0}},
{signal="signal-pink", color={r=1,g=0,b=1}},
{signal="signal-cyan", color={r=0,g=1,b=1}},
},
circuit_wire_connection_point =
{
shadow =
{
red = {0.734375, 0.578125},
green = {0.609375, 0.640625},
},
wire =
{
red = {0.40625, 0.34375},
green = {0.40625, 0.5},
}
},
circuit_connector_sprites = get_circuit_connector_sprites({0.1875, 0.28125}, {0.1875, 0.28125}, 18),
circuit_wire_max_distance = 36.5
},
{
type = "roboport",
name = "backbone-logistics",
icon = "__anarchy__/graphics/icons/backbone-icon.png",
flags = {"placeable-neutral", "placeable-off-grid", "player-creation"},
minable = {hardness = 0.2, mining_time = 1.5},
max_health = 350,
corpse = "small-remnants",
collision_box = {{0, 0}, {0, 0}},
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
logistics_radius = 18.5,
construction_radius = 36.5,
energy_source =
{
type = "electric",
usage_priority = "secondary-input",
input_flow_limit = "5MW",
buffer_capacity = "100MJ"
},
recharge_minimum = "5MJ",
energy_usage = "50KW",
charging_energy = "5MW",
robot_slots_count = 0,
material_slots_count = 0,
charge_approach_distance = 5,
charging_offsets =
{
{-1.5, -0.5}, {1.5, -0.5}, {1.5, 1.5}, {-1.5, 1.5},
},
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 1.0 },
base =
{
filename = "__anarchy__/graphics/entity/backbone.png",
width = 136,
height = 132,
shift = {1, -0.75}
},
base_animation =
{
filename = "__anarchy__/graphics/entity/blank.png",
priority = "medium",
width = 1,
height = 1,
frame_count = 1
},
base_patch =
{
filename = "__anarchy__/graphics/entity/blank.png",
width = 1,
height = 1,
frame_count = 1
},
door_animation_up =
{
filename = "__anarchy__/graphics/entity/blank.png",
width = 1,
height = 1,
frame_count = 1
},
door_animation_down =
{
filename = "__anarchy__/graphics/entity/blank.png",
width = 1,
height = 1,
frame_count = 1
},
recharging_animation =
{
filename = "__anarchy__/graphics/entity/blank.png",
width = 1,
height = 1,
frame_count = 1
},
recharging_light = {intensity = 0.4, size = 5},
request_to_open_door_timeout = 15,
spawn_and_station_height = 1.75,
draw_logistic_radius_visualization = true,
draw_construction_radius_visualization = true,
}
}
)