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.