Page 1 of 1

Clear Map

Posted: Wed Feb 03, 2016 9:06 pm
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

Re: Clear Map

Posted: Wed Feb 03, 2016 9:44 pm
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

Re: Clear Map

Posted: Thu Feb 04, 2016 1:05 am
by ratchetfreak
you can get the seed (IIRC) and map settings and then regenerate

Re: Clear Map

Posted: Thu Feb 04, 2016 8:36 am
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.

Re: Clear Map

Posted: Thu Feb 04, 2016 8:45 am
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

Re: Clear Map

Posted: Thu Feb 04, 2016 3:11 pm
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

Re: Clear Map

Posted: Thu Feb 04, 2016 3:26 pm
by Zeblote
You need to use /c [stuff] to run commands since 0.11, did you just send it as a chat message?

Re: Clear Map

Posted: Thu Feb 04, 2016 8:11 pm
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 :)

Re: Clear Map

Posted: Thu Feb 04, 2016 8:16 pm
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

Re: Clear Map

Posted: Thu Feb 04, 2016 8:23 pm
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 :)

Re: Clear Map

Posted: Thu Feb 04, 2016 8:36 pm
by prg
Add name="item-on-ground" to the find_entities_filtered call.