Jump to content

Recommended Posts

I'd like to make the lightning rod remove everything with the "heart" tag in a 1 tile radius around it whenever it is struck by lightning.

If I knew how to remove stuff with a certain tag in a radius, I think I could make it work. Thanks for reading

lightningrod.lua

--can be sth like this


local function removeheartinrange(inst)
    local x2, y2, z2 = inst.Transform:GetWorldPosition()
    local range = 4 --a tile is 4 wall grid
    local ents = TheSim:FindEntities(x2, y2, z2, range, { "heart" }, nil)
    for i, ent in ipairs(ents) do
        ent:Remove()
    end
end
AddPrefabPostInit("lightningrod",function(inst)
    if not GLOBAL.TheWorld.ismastersim then
        return inst
    end
    inst:ListenForEvent("lightningstrike", removeheartinrange)
end
)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...