I'm trying to remove decal when I change the terrain.
I'm running the below, but not getting any count. Can anyone see what I'm doing wrong.
Code: Select all
---------------------------------------------
local function Remove_Decal(surface, pos)
game.print("Decal Script running")
local radius = 2.5
local area = {{pos.x - radius, pos.y - radius}, {pos.x + radius, pos.y + radius}}
local decals = surface.find_entities_filtered({area = area, type = "optimized-decorative"})
game.print(#decals) -- Always 0
if (#decals > 0) then
game.print("Decal Found")
for i,decal in pairs(decals) do
if decal and decal.valid then
decal.destroy()
end
end
end
end