Page 1 of 1

[Script] Insert water / deep water into the map

Posted: Fri Jul 28, 2017 6:48 am
by Plawerth
If some idiot griefer has messed up your multiplayer world with landfill and you are unable to load a prior savegame, the following will allow you to repair the map and re-insert water back into the world again.

NOTES:
  • Doing this will disable achievements.
  • SAVE the game world in case you screw this up.
  • You need to be admin or in a single-player game to do this.
  • This works on the vanilla game without any mods.
  • Shallow water is always surrounded by shoreline, so changing 1 tile on bare ground actually changes a 3x3 area:
    Image
  • Deep water is always surrounded by shallow water at least 1 tile wide. Inserting a single deep water tile on bare land will include a 3x3 ring of shallow water around it, plus a 5x5 ring of shoreline around the shallow water:
    Image
Steps:
  1. Press F4 to show debug options, and select the second item in the list, "show-detailed-info", then press F4 again to hide debug options
  2. In the regular game view (not the map overview), your cursor position is shown on line 1 of the detailed info. Use your cursor to find the location(s) to be changed back to water.
To change a single tile at coordinate x= -53, y= 42 to shallow water:

Code: Select all

/command
local the_list={name = "water", position = {-53,42}}
game.player.surface.set_tiles{the_list}
(Copy and paste this into the console and it will convert to a single line. It still works.)

To change a rectangular area of tiles, use the cursor to find two coordinates in opposite corners of a rectangle, and plug those numbers into the following script. (This script also works to change a single tile, if both corner coordinates are set to be the same.)

Change area from x=60, y=40 to x=50,y=45 to shallow water:

Code: Select all

/command
local Corner1={60,40}
local Corner2={50,45}
local table={}
local x=0
local y=0
local count=0
local StepX=1
local StepY=1
if (Corner1[1] > Corner2[1]) then StepX=-1 end
if (Corner1[2] > Corner2[2]) then StepY=-1 end
for x=Corner1[1],Corner2[1],StepX do
  for y=Corner1[2],Corner2[2],StepY do
    count=count+1
    table[count]={name="water",position={x,y}}
  end
end
game.player.surface.set_tiles(table)
To place deep water, change the tile name to "deepwater".


[Search keywords: add water, add deep water, fix water, fix deep water, repair water, repair deep water, reactor grief, pump grief, reactor griefed, pump griefed, undo landfill, revert landfill, remove landfill]