Command to remove Crude Oil?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
NC16inthehouse
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue Mar 15, 2016 3:59 am
Contact:

Command to remove Crude Oil?

Post by NC16inthehouse »

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.
User avatar
MalcolmCooks
Filter Inserter
Filter Inserter
Posts: 253
Joined: Mon Apr 06, 2015 8:32 pm
Contact:

Re: Command to remove Crude Oil?

Post by MalcolmCooks »

You should be able to use this command:

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
but you will have to figure out what the name for the oil patches is and insert it instead of "stone-rock". Perhaps someone else knows?
If you make the player.position numbers large enough you can delete all oil patches in a very large area. However this won't prevent the game from generating crude oil in new areas so I suggest starting the map over with different resource gen settings. If you want to keep the same map then use the map exchange string
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Command to remove Crude Oil?

Post by prg »

Remove whatever you're pointing at:

Code: Select all

game.player.selected.destroy()
Remove half of the already generated oil:

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
Remove half of newly generated oil:

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)
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Command to remove Crude Oil?

Post by ssilk »

Moved to Gameplay Help.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Post Reply

Return to “Gameplay Help”