Page 1 of 1

[Resolved] Removal of entity not working as in 0.15

Posted: Thu Dec 21, 2017 10:20 pm
by TheSAguy
Hi,

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
REMOVE:

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


Re: Removal of entity not working as in 0.15

Posted: Thu Dec 21, 2017 11:28 pm
by Bilka
on_preplayer_mined was renamed to on_pre_player_mined

Re: Removal of entity not working as in 0.15

Posted: Fri Dec 22, 2017 12:50 am
by TheSAguy
Thanks!
Is there a list somewhere of changed names?

Re: Removal of entity not working as in 0.15

Posted: Fri Dec 22, 2017 12:55 am
by Bilka
TheSAguy wrote:Thanks!
Is there a list somewhere of changed names?
The changelog lists nearly all of them.

Re: [Resolved] Removal of entity not working as in 0.15

Posted: Fri Dec 22, 2017 2:18 am
by TheSAguy
Thanks.