Clear Map

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
Zenith
Inserter
Inserter
Posts: 20
Joined: Mon Jan 12, 2015 10:55 am
Contact:

Clear Map

Post by Zenith »

Hi everyone,

I'm at the point of wanting to redesign my initial factory (I'm just about to start blue science production and need a better layout).

Is there a command I can type in that will just remove all entities I have placed down in game (I know that's a big drastic but I'm OK with it).

As long as I'm still at the same level of science research I don't mind starting again, I can hopefully but some better thought into the layout then.

Thanks,

Zenith

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Clear Map

Post by prg »

Code: Select all

local s = game.local_player.surface
for chunk in s.get_chunks() do
    entities = s.find_entities_filtered{area={{chunk.x*32, chunk.y*32}, {chunk.x*32+32, chunk.y*32+32}}, force=game.local_player.force}
    for _, v in pairs(entities) do
        if v.type ~= "player" then
            v.destroy()
        end
    end
end
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Clear Map

Post by ratchetfreak »

you can get the seed (IIRC) and map settings and then regenerate

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Clear Map

Post by prg »

ratchetfreak wrote:you can get the seed (IIRC) and map settings and then regenerate
That way you'd lose all your current research progress.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Zenith
Inserter
Inserter
Posts: 20
Joined: Mon Jan 12, 2015 10:55 am
Contact:

Re: Clear Map

Post by Zenith »

prg wrote:

Code: Select all

local s = game.local_player.surface
for chunk in s.get_chunks() do
    entities = s.find_entities_filtered{area={{chunk.x*32, chunk.y*32}, {chunk.x*32+32, chunk.y*32+32}}, force=game.local_player.force}
    for _, v in pairs(entities) do
        if v.type ~= "player" then
            v.destroy()
        end
    end
end
Thanks prg I'll give this a go when I can and let you know.

Yes, you're quite correct I could regenerate or simply start again but I wanted to continue from where I left of with my existing research. Basically, I want to collect a bunch of the core resources up, then remove any items I've placed down so I can start fresh :)

Cheers

Zentih

Zenith
Inserter
Inserter
Posts: 20
Joined: Mon Jan 12, 2015 10:55 am
Contact:

Re: Clear Map

Post by Zenith »

Hi prg,

I tested this on a backup of my save and it didn't do anything. I stood in the middle of my factory with assembly machines and belts around me (within a couple of tiles) and run the command and nothing happened. Any ideas?

Thanks

Zenith

Zeblote
Filter Inserter
Filter Inserter
Posts: 973
Joined: Fri Oct 31, 2014 11:55 am
Contact:

Re: Clear Map

Post by Zeblote »

You need to use /c [stuff] to run commands since 0.11, did you just send it as a chat message?

Zenith
Inserter
Inserter
Posts: 20
Joined: Mon Jan 12, 2015 10:55 am
Contact:

Re: Clear Map

Post by Zenith »

not sure, I thought I did /c because that's what I've done with other commands, but I'll admit I'm coming back to factorio after quite a break from it so probably my fault. I'll test it again now and let you know :)

Zenith
Inserter
Inserter
Posts: 20
Joined: Mon Jan 12, 2015 10:55 am
Contact:

Re: Clear Map

Post by Zenith »

My apologies PRG this works perfectly and has removed all the furnaces etc.

The only issue I have now is that it's left behind things that were on the belts, they are now all just lying on the floor.

Is there a command to remove these as well (i'm going to go searching the forum at the same time as posting this, will update if I find anything)

Thanks,


zenith

Zenith
Inserter
Inserter
Posts: 20
Joined: Mon Jan 12, 2015 10:55 am
Contact:

Re: Clear Map

Post by Zenith »

Code: Select all

/c local s = game.local_player.surface
for chunk in s.get_chunks() do
    entities = s.find_entities_filtered{area={{chunk.x*32, chunk.y*32}, {chunk.x*32+32, chunk.y*32+32}}}
    for _, v in pairs(entities) do
        if v.type ~= "player" then
            v.destroy()
        end
    end
end
This kind of did what I wanted, it basically cleared out everything so I just have a blank map. It also cleared out the ore spawn and oil and everything but that's fine as I can just cheat to put some of that back in :)

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Clear Map

Post by prg »

Add name="item-on-ground" to the find_entities_filtered call.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Post Reply

Return to “Gameplay Help”