2018-01-19 23:33:54 +02:00
|
|
|
require "map_gen.combined.grilledham_map_gen.builders"
|
2017-11-10 14:03:46 +02:00
|
|
|
|
2018-01-19 23:33:54 +02:00
|
|
|
local pic = require "map_gen.data.UK"
|
2017-11-10 14:03:46 +02:00
|
|
|
local pic = decompress(pic)
|
|
|
|
local map = picture_builder(pic)
|
|
|
|
|
|
|
|
-- this changes the size of the map
|
|
|
|
map = scale(map, 2, 2)
|
|
|
|
|
2017-11-12 16:55:55 +02:00
|
|
|
-- this moves the map, effectively changing the spawn point.
|
2017-11-10 14:03:46 +02:00
|
|
|
map = translate(map, 0, 10)
|
|
|
|
|
|
|
|
-- this sets the tile outside the bounds of the map to deepwater, remove this and it will be void.
|
|
|
|
map = change_tile(map, false, "deepwater")
|
|
|
|
|
|
|
|
function run_combined_module(event)
|
|
|
|
local area = event.area
|
|
|
|
local surface = event.surface
|
|
|
|
MAP_GEN_SURFACE = surface
|
|
|
|
local tiles = {}
|
|
|
|
local entities = {}
|
|
|
|
|
|
|
|
local top_x = area.left_top.x
|
|
|
|
local top_y = area.left_top.y
|
|
|
|
|
|
|
|
-- place tiles over the edge of chunks to reduce tile artefacts on chunk boundaries.
|
|
|
|
for y = top_y - 1, top_y + 32 do
|
|
|
|
for x = top_x - 1, top_x + 32 do
|
2017-11-12 16:55:55 +02:00
|
|
|
|
2017-11-10 14:03:46 +02:00
|
|
|
-- local coords need to be 'centered' to allow for correct rotation and scaling.
|
2017-11-12 16:55:55 +02:00
|
|
|
local tile, entity = map(x + 0.5, y + 0.5, x, y)
|
2017-11-10 14:03:46 +02:00
|
|
|
|
2017-11-12 16:55:55 +02:00
|
|
|
if type(tile) == "boolean" and not tile then
|
|
|
|
table.insert( tiles, {name = "out-of-map", position = {x, y}} )
|
2017-11-10 14:03:46 +02:00
|
|
|
elseif type(tile) == "string" then
|
2017-11-12 16:55:55 +02:00
|
|
|
table.insert( tiles, {name = tile, position = {x, y}} )
|
2017-11-10 14:03:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if entity then
|
|
|
|
table.insert(entities, entity)
|
|
|
|
end
|
|
|
|
end
|
2017-11-12 16:55:55 +02:00
|
|
|
end
|
|
|
|
|
2017-11-10 14:03:46 +02:00
|
|
|
-- set tiles.
|
|
|
|
surface.set_tiles(tiles, true)
|
|
|
|
|
|
|
|
-- set entities
|
2017-11-12 16:55:55 +02:00
|
|
|
for _, v in ipairs(entities) do
|
|
|
|
if surface.can_place_entity(v) then
|
|
|
|
surface.create_entity(v)
|
2017-11-10 14:03:46 +02:00
|
|
|
end
|
2017-11-12 16:55:55 +02:00
|
|
|
end
|
|
|
|
end
|