Creating an empty map?

This is the place to share custom user maps, scenarios, and campaigns.
Post Reply
Slackie
Inserter
Inserter
Posts: 24
Joined: Mon Mar 20, 2017 10:29 am
Contact:

Creating an empty map?

Post by Slackie »

Hey all. Wondering if it's possible to create an entirely empty map? I want to create a custom map with pre-defined resource locations, removing everything else on the map. To be clear I want to start with the entire world being empty, no trees, resources, water, etc.

I've so far accomplished this in the map editor by creating massive water areas (so that everything where the water is placed will be deleted) and then filling in the water with land to create an empty square of land, but this seems sub-optimal.

Anyone done this before?

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

Re: Creating an empty map?

Post by darkfrei »

Here was custom map generation.

[MOD 0.14.x] Water maze
viewtopic.php?f=94&t=21568
https://m.imgur.com/a/wptLh

Slackie
Inserter
Inserter
Posts: 24
Joined: Mon Mar 20, 2017 10:29 am
Contact:

Re: Creating an empty map?

Post by Slackie »

darkfrei wrote:Here was custom map generation.

[MOD 0.14.x] Water maze
viewtopic.php?f=94&t=21568
https://m.imgur.com/a/wptLh
Thanks for the link, that looks similar to what I am trying to do.

I found some modified code in that thread on the last page which illustrates how to make the chunk generator generate only water chunks, but when I follow the instructions for making it generate only land chunks, it generates land with resources on it!

So, somehow I need to either figure out how to generate land and then wipe it as part of chunk generation, or I need to do a second pass after generating water and convert it to land.

Anyone have an idea how I could modify the water maze mod to do that?

abregado
Former Staff
Former Staff
Posts: 282
Joined: Sat Aug 30, 2014 9:43 am
Contact:

Re: Creating an empty map?

Post by abregado »

You can override the autoplace controls when you create a new surface.

Have a read in the documentation here http://lua-api.factorio.com/latest/LuaG ... te_surface

When providing a MapSettings table, provide an empty autoplace controls object. It should generate nothing at all.

Slackie
Inserter
Inserter
Posts: 24
Joined: Mon Mar 20, 2017 10:29 am
Contact:

Re: Creating an empty map?

Post by Slackie »

Surfaces sound promising... I ended up making a little mod to do it:

Code: Select all

local function make_chunk(event)
    local x1 = event.area.left_top.x
    local y1 = event.area.left_top.y
    local x2 = event.area.right_bottom.x
    local y2 = event.area.right_bottom.y
    local surface = event.surface
    local replace_type = "dirt-dark"

    tiles = {}

    for x = x1, x2 do
        for y = y1, y2 do
            local existing_type = surface.get_tile(x, y).name

            if existing_type ~= replace_type then
                table.insert(tiles, {name = replace_type, position = {x, y}})
            end
        end
    end

    surface.set_tiles(tiles)

    for key, entity in pairs(event.surface.find_entities(event.area)) do
        if entity.type ~= "player" then
            entity.destroy()
        end
    end

    surface.destroy_decoratives(event.area)
end

local function on_load(event)
    script.on_event(defines.events.on_chunk_generated, make_chunk)
end

local function on_init(event)
    on_load(nil)
end

script.on_init(on_init)
script.on_load(on_load)

Post Reply

Return to “Maps and Scenarios”