How to create an empty map
Posted: Wed Jan 29, 2020 7:33 am
In the data-final-fixes*** phase, deep copy an autoplace table from an existing autoplace-capable tile add an empty autoplace:
Thanks to https://mods.factorio.com/user/mugiwaxar. They found an amazingly easier and not error-prone way:
I used dirt-6 because I was looking at 61754 while testing things.
New map settings:
Posting it on the forum so people can find it while searching, for creating a truly empty map. If cliffiness is not set, then you can enter editor mode, zoom out, shift-click to force place tiles at the edge of view, and cliffs will spawn as you enter further chunks. The same effect can happen if the player has a very high running speed. Chunk generation is independent of things existing within the area of the chunk already (tiles are placed, and then other things take more time, during which the player can reach the chunk and place things).
To add tiles via script, do a double-for loop at the offset off a position, store the result tiles in a table as tile{name = "name", position = {x = x, y = y}}
Example, modified from on_chunk_generated event in ComfyFactorio-0.2:
The above command will replace tiles in the chunk one above the player with refined concrete (-32 tiles in y from the current chunks corner).
The upper left corner is the "start" of a chunk (least x, least y). The chunk can be seen with Debug Settings (F4), always tab, option show-active-chunks, more than halfway down. A pink square will be on the mini-map if the character or something else active is in it.
Using .5 to 31.5 avoids any potential boundary or rounding issues. Going from 0 to 31 seems to work (the upper left starting corners of the tiles).
To place a tile over out-of-map, it must have no collision mask that matches out-of-map. Using table.deepcopy and copying out of map to create a new tile is recommend-able for this purpose (also if tile is to become an item). Non-collision can be done with an empty condition table on the item, or use an unused collision mask and add it to everything you don't want it to collide with. The latter has potential mod conflicts, unless you can find an unused collision group (layer11-layer15) and add that one to everything that can be placed. An empty condition does permit it to be used as landfill, but there's currently no other way to directly achieve the same effect. Many control functions could be used to refund the tile or remove a ghost (a tile-ghost is an entity, not a tile) and print a message to the player if it's on the wrong surface, wrong area, overwrote the wrong tile, etc.
Thanks to https://mods.factorio.com/user/mugiwaxar. They found an amazingly easier and not error-prone way:
Code: Select all
data.raw.tile["out-of-map"].autoplace = { default_enabled = false }
New map settings:
Code: Select all
local my_map_gen_settings = {
default_enable_all_autoplace_controls = false,
property_expression_names = {cliffiness = 0},
autoplace_settings = {tile = {settings = { ["out-of-map"] = {frequency="normal", size="normal", richness="normal"} }}},
starting_area = "none"
}
To add tiles via script, do a double-for loop at the offset off a position, store the result tiles in a table as tile{name = "name", position = {x = x, y = y}}
Example, modified from on_chunk_generated event in ComfyFactorio-0.2:
Code: Select all
/c
local pos = game.player.position
local chunk_left_top = {x = math.floor(pos.x / 32) * 32, y = math.floor(pos.y / 32) * 32 - 32}
local event = {surface = game.player.surface, area = {left_top = chunk_left_top}}
local surface = event.surface
local left_top = event.area.left_top
local tiles = {}
for x = 0.5, 31.5, 1 do
for y = 0.5, 31.5, 1 do
table.insert(tiles, {name = "refined-concrete", position = {x = left_top.x + x, y = left_top.y + y}})
end
end
surface.set_tiles(tiles)
The upper left corner is the "start" of a chunk (least x, least y). The chunk can be seen with Debug Settings (F4), always tab, option show-active-chunks, more than halfway down. A pink square will be on the mini-map if the character or something else active is in it.
Using .5 to 31.5 avoids any potential boundary or rounding issues. Going from 0 to 31 seems to work (the upper left starting corners of the tiles).
To place a tile over out-of-map, it must have no collision mask that matches out-of-map. Using table.deepcopy and copying out of map to create a new tile is recommend-able for this purpose (also if tile is to become an item). Non-collision can be done with an empty condition table on the item, or use an unused collision mask and add it to everything you don't want it to collide with. The latter has potential mod conflicts, unless you can find an unused collision group (layer11-layer15) and add that one to everything that can be placed. An empty condition does permit it to be used as landfill, but there's currently no other way to directly achieve the same effect. Many control functions could be used to refund the tile or remove a ghost (a tile-ghost is an entity, not a tile) and print a message to the player if it's on the wrong surface, wrong area, overwrote the wrong tile, etc.