[Resolved] Removal of entity not working as in 0.15

Place to get help with not working mods / modding interface.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

[Resolved] Removal of entity not working as in 0.15

Post 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

Attachments
Bio_Industries_2.0.2.zip
MOD
(8.1 MiB) Downloaded 103 times
Last edited by TheSAguy on Fri Dec 22, 2017 2:18 am, edited 1 time in total.
Bilka
Factorio Staff
Factorio Staff
Posts: 3470
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Removal of entity not working as in 0.15

Post by Bilka »

on_preplayer_mined was renamed to on_pre_player_mined
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Removal of entity not working as in 0.15

Post by TheSAguy »

Thanks!
Is there a list somewhere of changed names?
Bilka
Factorio Staff
Factorio Staff
Posts: 3470
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Removal of entity not working as in 0.15

Post by Bilka »

TheSAguy wrote:Thanks!
Is there a list somewhere of changed names?
The changelog lists nearly all of them.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

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

Post by TheSAguy »

Thanks.
Post Reply

Return to “Modding help”