Advertisement
aum7

working lua script - removed also trees on map

Nov 28th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | Source Code | 0 0
  1. -- Define map boundaries
  2. local mapMinX, mapMinY = 0, 0
  3. local mapMaxX, mapMaxY = 1024, 1024
  4.  
  5. -- Function to check if an entity's position is outside the map area
  6. local function isOutsideMapArea(position)
  7.     local x, y = position[1], position[2]
  8.     return x < mapMinX or x > mapMaxX or y < mapMinY or y > mapMaxY
  9. end
  10.  
  11. -- Fetch all ASSET_GROUP entities
  12. for id, asset in pairs(game.interface.getEntities({radius = 1e42}, {type = "ASSET_GROUP", includeData = true})) do
  13.     if asset.position and isOutsideMapArea(asset.position) then
  14.         print("Removing entity with ID: " .. tostring(id)) -- Debugging line
  15.         api.cmd.sendCommand(api.cmd.make.removeField(id))  -- Remove the entity
  16.     end
  17. end
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement