1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

Added Builders.change_map_gen_tiles(shape, new_tile_map).

This commit is contained in:
grilledham 2019-09-11 20:51:04 +01:00
parent 1ad53c842d
commit e96cbfa680
2 changed files with 28 additions and 6 deletions

View File

@ -75,18 +75,14 @@ local no_water_grid = b.choose(is_not_water_tile, grid, b.full_shape)
local map = b.if_else(no_water_grid, b.full_shape)
map = b.translate(map,1,1)
-- replace grass tiles with dirt so that the rail grid is much
local tile_map ={
['grass-1'] = 'dirt-1',
['grass-2'] = 'dirt-2',
['grass-3'] = 'dirt-3',
['grass-4'] = 'dirt-4',
}
-- replace grass tiles with dirt so that the rail grid is much
for old_tile, new_tile in pairs(tile_map) do
map = b.change_map_gen_tile(map, old_tile, new_tile)
end
map = b.change_map_gen_tiles(map, tile_map)
-- This event removes rail and curve rail entities and removes them unless they are placed on landfill
Event.add(

View File

@ -1497,6 +1497,32 @@ function Builders.change_map_gen_tile(shape, old_tile, new_tile)
end
end
-- only changes tiles made by the factorio map generator.
function Builders.change_map_gen_tiles(shape, new_tile_map)
return function(x, y, world)
local function handle_tile(tile)
if type(tile) == 'boolean' and tile then
local gen_tile = world.surface.get_tile(world.x, world.y).name
local new_tile = new_tile_map[gen_tile]
if new_tile ~= nil then
return new_tile
end
end
return tile
end
local tile = shape(x, y, world)
if type(tile) == 'table' then
tile.tile = handle_tile(tile.tile)
else
tile = handle_tile(tile)
end
return tile
end
end
function Builders.change_map_gen_hidden_tile(shape, old_tile, hidden_tile)
return function(x, y, world)
local function is_collides()