How to create an empty map

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

How to create an empty map

Post by Honktown »

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:

Code: Select all

data.raw.tile["out-of-map"].autoplace = { default_enabled = false }
I used dirt-6 because I was looking at 61754 while testing things.

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"
	}
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:

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 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.
Last edited by Honktown on Mon Feb 10, 2020 1:18 am, edited 3 times in total.
I have mods! I guess!
Link

billbo99
Fast Inserter
Fast Inserter
Posts: 131
Joined: Fri Nov 02, 2018 9:19 am
Contact:

Re: How to create an empty map

Post by billbo99 »

For an empty world I like this mod

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

Or you can go into `/editor` and in the surfaces tab and make similar changes there.

Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: How to create an empty map

Post by Honktown »

Part of the reason I wanted to figure this out was Mobile Factory's behavior is to have a buildable platform on a surface with a surface sized 1x1, which places out-of-map tiles outside normal range. The game sticks up a middle finger when you replace out-of-map tiles with the buildable tiles the mod provides, and doesn't permit radars/mini-map to work. It generates chunks according to the chunk counter in F5 and game-crippling lag if forcing a ton to generate, but then doesn't process them further. Only chunks in-bounds can be mapped (may be worth reporting as a bug).

Another reason was I didn't see any non-control way to empty maps/chunks. There should have been a way to do it via map generation. Unfortunately collision masks can't be inverted or tile-specific, so there's no way to limit built tiles to anything but the pre-defined collision masks or nothing.
I have mods! I guess!
Link

Post Reply

Return to “Modding discussion”