[SOLVED] Need help with mass deleting chunks (function)

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
QuackerJ4ck
Inserter
Inserter
Posts: 44
Joined: Wed Apr 06, 2016 4:06 pm
Contact:

[SOLVED] Need help with mass deleting chunks (function)

Post by QuackerJ4ck »

Hi guys,

I revealed a "little" too much of a map and to crop the savefile and save performance i want to delete pretty much all chunks around my base.

I know there is the command

Code: Select all

/c game.player.surface.delete_chunk{X, Y}
But doing this by hand would take me around 45 years

I need pretty much a function that deletes all the chunks from the outer frame to the inner one (if possible near the red area)
Starting Area (around 0,0) is the green Circle.

Is the function able to do that?

When you need more data or coords of the map; i'm more than happy to provide that.

I hope someone can help me :-)
Attachments
Base.png
Base.png (1.66 MiB) Viewed 4584 times
Zwischenablage01.jpg
Zwischenablage01.jpg (632.21 KiB) Viewed 4584 times
Last edited by QuackerJ4ck on Thu May 11, 2017 8:00 pm, edited 1 time in total.

SpeedDaemon
Fast Inserter
Fast Inserter
Posts: 124
Joined: Fri May 22, 2015 3:31 pm
Contact:

Re: Need help with mass deleting chunks (function)

Post by SpeedDaemon »

I think you can put LUA scripts, including loops, into the game console, which would mean you could automate running the delete_chunk command... I don't have an example available right now, though.

EDIT:
Try this:

Code: Select all

/c for x=<start>,<end> do
   for y=<start>,<end> do
       game.player.surface.delete_chunk{x, y}
   end
end
Replace <start> and <end> with range of x/y coords you want to remove. You'll need to run this four times to delete rectangles of chunks around the area you want to keep.

QuackerJ4ck
Inserter
Inserter
Posts: 44
Joined: Wed Apr 06, 2016 4:06 pm
Contact:

Re: Need help with mass deleting chunks (function)

Post by QuackerJ4ck »

I love you forever - worked like a charm.

darklich14
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Sat Feb 24, 2018 3:07 am
Contact:

Re: [SOLVED] Need help with mass deleting chunks (function)

Post by darklich14 »

No warranty:

Code: Select all

/c 
ltx = 227 
lty = 278 
rbx = 597 
rby = 3964 
for chunk in game.player.surface.get_chunks() do 
  a = chunk.area 
  if not (a.left_top.x > ltx and a.right_bottom.x < rbx and 
    a.left_top.y > lty and a.right_bottom.y < rby) then 
    game.player.surface.delete_chunk({chunk.x, chunk.y})
  end 
end
I'm trying to remove chunks all around a bounding box. It is burning my CPU at the moment running on a 200MB map so it's either doing the right thing or not but it's definitely deleting chunks.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: [SOLVED] Need help with mass deleting chunks (function)

Post by FuryoftheStars »

darklich14 wrote:
Sat Mar 05, 2022 2:22 am
No warranty:

Code: Select all

/c 
ltx = 227 
lty = 278 
rbx = 597 
rby = 3964 
for chunk in game.player.surface.get_chunks() do 
  a = chunk.area 
  if not (a.left_top.x > ltx and a.right_bottom.x < rbx and 
    a.left_top.y > lty and a.right_bottom.y < rby) then 
    game.player.surface.delete_chunk({chunk.x, chunk.y})
  end 
end
I'm trying to remove chunks all around a bounding box. It is burning my CPU at the moment running on a 200MB map so it's either doing the right thing or not but it's definitely deleting chunks.
There are a couple of mods out there that’ll delete unused chunks. Of the two I’m thinking of, one is automatic periodically, the other is on-demand via a gui button.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

darklich14
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Sat Feb 24, 2018 3:07 am
Contact:

Re: [SOLVED] Need help with mass deleting chunks (function)

Post by darklich14 »

Thank you, but between a mod and a command, I'll take the command. I'm a vanilla *enthusiast* :D

Good recs though for those who do mods!

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: [SOLVED] Need help with mass deleting chunks (function)

Post by FuryoftheStars »

I’m not sure I understand the difference seems (last I knew) /c commands disable achievements as well (and you can disable the mod once you’re done with it), but ok. :)
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 2420
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: [SOLVED] Need help with mass deleting chunks (function)

Post by BlueTemplar »

Achievements are tracked separately for modded ones :
https://mods.factorio.com/mod/MoreAchievements
(Also Steam doesn't track modded achievements, if you're using it in the first place...)
BobDiggity (mod-scenario-pack)

Post Reply

Return to “Gameplay Help”