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

47 lines
1.2 KiB
Lua
Raw Normal View History

2017-08-12 02:20:08 +02:00
require("locale.gen_combined.grilledham_map_gen.builders")
function run_combined_module(event)
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-08-25 07:27:50 +02:00
-- local coords need to be 'centered' to allow for correct rotation and scaling.
local tile, entity = MAP_GEN(x + 0.5, y + 0.5, x, y)
2017-08-12 02:20:08 +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
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
end
2017-08-12 02:20:08 +02:00
-- 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)
2017-08-12 02:20:08 +02:00
end
end
end