Command to remove Crude Oil?
Posted: Tue Mar 15, 2016 4:02 am
I spawned too much crude oil and I don't know how to remove it.I tried the Wiki and changing the entity but to no avail.
Code: Select all
/c for _,entity in pairs(game.local_player.surface.find_entities_filtered{
area={{game.local_player.position.x-32, game.local_player.position.y-32},
{game.local_player.position.x+32, game.local_player.position.y+32}},
name="stone-rock"})
do
entity.destroy()
end
Code: Select all
game.player.selected.destroy()
Code: Select all
for chunk in game.local_player.surface.get_chunks() do
oil_wells = game.local_player.surface.find_entities_filtered{name="crude-oil", area={{chunk.x*32, chunk.y*32}, {(chunk.x+1)*32, (chunk.y+1)*32}}}
for _, v in pairs(oil_wells) do
if math.random() > .5 then v.destroy() end
end
end
Code: Select all
script.on_event(defines.events.on_chunk_generated, function(event)
oil_wells = event.surface.find_entities_filtered{name="crude-oil", area=event.area}
for _, v in pairs(oil_wells) do
if math.random() > .5 then v.destroy() end
end
end)