1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/locale/gen_combined/grilledham_map_gen/map_gen.lua
2017-08-12 01:20:08 +01:00

45 lines
1.2 KiB
Lua

require("locale.gen_combined.grilledham_map_gen.builders")
function run_combined_module(event)
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
local tile, entity = MAP_GEN(x, y, x, y)
if type(tile) == "boolean" and not tile then
table.insert( tiles, {name = "out-of-map", position = {x, y}} )
elseif type(tile) == "string" then
table.insert( tiles, {name = tile, position = {x, y}} )
end
if entity then
table.insert(entities, entity)
end
end
end
-- set tiles.
surface.set_tiles(tiles, false)
-- set entities
for _, v in ipairs(entities) do
if surface.can_place_entity(v) then
surface.create_entity(v)
end
end
end