Remove all items on transport-belts

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
RAID_BOMB
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu May 30, 2019 8:46 pm
Contact:

Remove all items on transport-belts

Post by RAID_BOMB »

Hey i wanted to see all my machines running at once so i asked myself if there is any way to remove all items that exist in my world
any help is appreciated

adam_bise
Filter Inserter
Filter Inserter
Posts: 358
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Remove all items on transport-belts

Post by adam_bise »

Well, you could create a massive blueprint of your map, right click / remove all entities in the BP except belts, splitters, and undergrounds, then create a deconstruction planner that whitelists all belts, splitters and undergrounds. Then use the decon planner over your whole base, and re-stamp the belt ghosts with the 1st blueprint.

Assuming all areas are within roboport construction radius and you have enough storage for the decon.

I would back up your save before doing such a thing.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Remove all items on transport-belts

Post by DaveMcW »

Code: Select all

/c 
for _, type in pairs{"transport-belt","underground-belt","splitter"} do
  for _, belt in pairs(game.player.surface.find_entities_filtered{type=type}) do
    for i = 1, belt.get_max_transport_line_index() do
      belt.get_transport_line(i).clear()
    end
  end
end

RAID_BOMB
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu May 30, 2019 8:46 pm
Contact:

Re: Remove all items on transport-belts

Post by RAID_BOMB »

i treied the code out and it said: "cannot execture command. Error: LuaEntity doesn't contain key get_may_transport_line_index. stack traceback [string "for _, type in pairs{"transport-belt","under..."]:1: in main chunk"

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Remove all items on transport-belts

Post by DaveMcW »

Copy/paste it, don't try to type it manually.

You can copy with Ctrl C or Command C, and paste with Ctrl V or Command V.

RAID_BOMB
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu May 30, 2019 8:46 pm
Contact:

Re: Remove all items on transport-belts

Post by RAID_BOMB »

I copied it and it didnt work......

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Remove all items on transport-belts

Post by DaveMcW »

Ah, you must be on 0.16 still. This code should work, but it might miss some underground belts.

Code: Select all

for _, type in pairs{"transport-belt","underground-belt","splitter"} do
  for _, belt in pairs(game.player.surface.find_entities_filtered{type=type}) do
    for i = 1, 2 do
      belt.get_transport_line(i).clear()
    end
  end
end

RAID_BOMB
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu May 30, 2019 8:46 pm
Contact:

Re: Remove all items on transport-belts

Post by RAID_BOMB »

Sorry that i posted last time so long ago.... Went out on a camping trip. I tried the code out and it returned no error but didnt do anything at all...

Post Reply

Return to “Gameplay Help”