Page 1 of 1

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

Posted: Thu May 11, 2017 7:27 pm
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 :-)

Re: Need help with mass deleting chunks (function)

Posted: Thu May 11, 2017 7:31 pm
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.

Re: Need help with mass deleting chunks (function)

Posted: Thu May 11, 2017 8:00 pm
by QuackerJ4ck
I love you forever - worked like a charm.

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

Posted: Sat Mar 05, 2022 2:22 am
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.

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

Posted: Sat Mar 05, 2022 3:51 am
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.

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

Posted: Sat Mar 05, 2022 6:40 pm
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!

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

Posted: Sat Mar 05, 2022 9:41 pm
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. :)

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

Posted: Thu Mar 10, 2022 2:05 pm
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...)