I'm updating my Mod to 0.16 and my function to remove hidden entities is not working for me.
When I mine the entity, it's not registering it for me.
Could someone please let me know how I should fix this.
I've also attached the mod if needed.
This is what I had before:
BUILT:
Code: Select all
--------------------------------------------------------------------
local function On_Built(event)
local entity = event.created_entity
local surface = entity.surface
local force = entity.force
local position = entity.position
--- Bio Farm has been built
if entity.valid and entity.name == "bi_bio_farm" then
writeDebug("Bio Farm has been built")
local b_farm = entity
local pole_name = "bi_medium-electric-pole_for_Bio_Farm"
local panel_name = "bi_solar-panel_for_Bio_Farm"
local lamp_name = "bi_light_for_Bio_Farm"
local create_pole = surface.create_entity({name = pole_name, position = position, force = force})
local create_panel = surface.create_entity({name = panel_name, position = position, force = force})
local create_lamp = surface.create_entity({name = lamp_name, position = position, force = force})
create_pole.minable = false
create_pole.destructible = false
create_panel.minable = false
create_panel.destructible = false
create_lamp.minable = false
create_lamp.destructible = false
group_entities(cantor(position.x,position.y), { b_farm, create_pole, create_panel, create_lamp })
end
end
Code: Select all
local function On_Remove(event)
local entity = event.entity
--- Bio Farm has been removed
if entity.valid and entity.name == "bi_bio_farm" then
writeDebug("Bio Farm has been removed")
local pos_hash = cantor(entity.position.x,entity.position.y)
local entity_group = getGroup_entities(pos_hash)
if entity_group then
for ix, vx in ipairs(entity_group) do
if vx == entity then
--vx.destroy()
else
vx.destroy()
end
end
end
ungroup_entities(pos_hash)
end
end