2017-08-12 02:20:08 +02:00
|
|
|
require("locale.gen_combined.grilledham_map_gen.builders")
|
|
|
|
|
|
|
|
function run_combined_module(event)
|
2017-11-12 15:11:06 +02:00
|
|
|
|
2017-08-12 02:20:08 +02:00
|
|
|
if MAP_GEN == nil then
|
|
|
|
game.print("MAP_GEN not set")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
for y = top_y, top_y + 31 do
|
|
|
|
for x = top_x, top_x + 31 do
|
2017-11-12 15:11:06 +02:00
|
|
|
|
2017-08-25 07:27:50 +02:00
|
|
|
-- local coords need to be 'centered' to allow for correct rotation and scaling.
|
2017-11-12 15:11:06 +02:00
|
|
|
local tile, entity = MAP_GEN(x + 0.5, y + 0.5, x, y)
|
2017-08-12 02:20:08 +02:00
|
|
|
|
2017-11-12 15:11:06 +02:00
|
|
|
if type(tile) == "boolean" and not tile then
|
|
|
|
table.insert( tiles, {name = "out-of-map", position = {x, y}} )
|
2017-08-12 02:20:08 +02:00
|
|
|
elseif type(tile) == "string" then
|
2017-11-12 15:11:06 +02:00
|
|
|
table.insert( tiles, {name = tile, position = {x, y}} )
|
2017-08-12 02:20:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if entity then
|
|
|
|
table.insert(entities, entity)
|
|
|
|
end
|
|
|
|
end
|
2017-11-12 15:11:06 +02:00
|
|
|
end
|
2017-08-12 02:20:08 +02:00
|
|
|
|
|
|
|
-- set tiles.
|
|
|
|
surface.set_tiles(tiles, false)
|
|
|
|
|
|
|
|
-- set entities
|
2017-11-12 15:11:06 +02:00
|
|
|
for _, v in ipairs(entities) do
|
|
|
|
if surface.can_place_entity(v) then
|
|
|
|
surface.create_entity(v)
|
2017-08-12 02:20:08 +02:00
|
|
|
end
|
2017-11-12 15:11:06 +02:00
|
|
|
end
|
|
|
|
end
|