Commands to change all tiles to lab tiles

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 883
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Commands to change all tiles to lab tiles

Post by Impatient »

What are the commands to

a) change all tiles in exiting chunks to lab tiles
b) make newly charted chunks only contain lab tiles (also excluding deco, trees, cliffs, resources, biters, ...)

I want to turn an existing world into a lab world.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Commands to change all tiles to lab tiles

Post by darkfrei »

by all surfaces
by all chunks
get chunk area
go x from 0 to 31
go y from 0 to 31
for every x and y as position in this chunk run the function

Code: Select all

function replace_floor_with (position, surface)
  if ((position.x + position.y)%2 == 0) then
    return "lab-dark-1"
  else
    return "lab-dark-2"
  end
end
add them to the table

Code: Select all

new_tiles[#new_tiles+1] = {name = replace_floor_with (position, surface), position = position}

See also https://mods.factorio.com/mod/lab-floor

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2916
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Commands to change all tiles to lab tiles

Post by Optera »

Convert existing worlds into labs:
1) open /editor
2) go into surfaces, select the surface and click "fill with lab tiles"
don't forget also checking "generate new chunks with lab tiles"

Sadly the editor doesn't come with buttons to remove cliffs, grass, rocks and trees.
Removing all of those at once including modded versions get a bit involved but this will work in console:

Code: Select all

/c
local surface = game.surfaces["nauvis"]
surface.destroy_decoratives{}
for _, entity in pairs(surface.find_entities_filtered{type = "cliff"} ) do
  entity.destroy()
end
local tree_names = {}
for name, prototype in pairs(game.entity_prototypes) do
  local autoplace = prototype.autoplace_specification
  if autoplace and autoplace.peaks then
    for _, peak in pairs(autoplace.peaks) do
      if peak.noise_layer == "rocks" or peak.noise_layer == "trees" then
        tree_names[#tree_names+1] = name
        break
      end
    end
  end
end
for _, entity in pairs(surface.find_entities_filtered{name = tree_names} ) do
  entity.destroy()
end

User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 883
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: Commands to change all tiles to lab tiles

Post by Impatient »

Thanks!

Post Reply

Return to “Modding help”