mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
line and square map
This commit is contained in:
parent
4a2b24a6f6
commit
fab41fbf8b
@ -1,4 +1,4 @@
|
||||
_DEBUG = false
|
||||
_DEBUG = true
|
||||
|
||||
global.scenario = {}
|
||||
global.spys = {"valansch", "air20"}
|
||||
|
62
map_gen/presets/lines_and_squares.lua
Normal file
62
map_gen/presets/lines_and_squares.lua
Normal file
@ -0,0 +1,62 @@
|
||||
local b = require 'map_gen.shared.builders'
|
||||
local Random = require 'map_gen.shared.random'
|
||||
|
||||
local track_seed1 = 1000
|
||||
local track_seed2 = 2000
|
||||
|
||||
local track_block_size = 30
|
||||
local track_lines = 50
|
||||
local track_chance = 6 -- 1 in x
|
||||
|
||||
local h_track = {
|
||||
b.line_x(2),
|
||||
b.translate(b.line_x(2), 0, -3),
|
||||
b.translate(b.line_x(2), 0, 3),
|
||||
b.rectangle(2, 10),
|
||||
b.translate(b.rectangle(2, 10), 15, 0),
|
||||
b.translate(b.rectangle(2, 10), -15, 0)
|
||||
}
|
||||
|
||||
h_track = b.any(h_track)
|
||||
h_track = b.single_x_pattern(h_track, 30)
|
||||
|
||||
local v_track = {
|
||||
b.line_y(2),
|
||||
b.translate(b.line_y(2), -3, 0),
|
||||
b.translate(b.line_y(2), 3, 0),
|
||||
b.rectangle(10, 2),
|
||||
b.translate(b.rectangle(10, 2), 0, 15),
|
||||
b.translate(b.rectangle(10, 2), 0, -15)
|
||||
}
|
||||
|
||||
v_track = b.any(v_track)
|
||||
v_track = b.single_y_pattern(v_track, 30)
|
||||
|
||||
local random = Random.new(track_seed1, track_seed2)
|
||||
|
||||
local function do_track_lines(track_shape)
|
||||
local track_pattern = {}
|
||||
|
||||
for _ = 1, track_lines do
|
||||
local shape
|
||||
if random:next_int(1, track_chance) == 1 then
|
||||
shape = track_shape
|
||||
else
|
||||
shape = b.empty_shape()
|
||||
end
|
||||
|
||||
table.insert(track_pattern, shape)
|
||||
end
|
||||
|
||||
return track_pattern
|
||||
end
|
||||
|
||||
local h_tracks = do_track_lines(h_track)
|
||||
h_tracks = b.grid_y_pattern(h_tracks, track_lines, track_block_size)
|
||||
|
||||
local v_tracks = do_track_lines(v_track)
|
||||
v_tracks = b.grid_x_pattern(v_tracks, track_lines, track_block_size)
|
||||
|
||||
local tracks = b.any {h_tracks, v_tracks}
|
||||
|
||||
return tracks
|
@ -693,6 +693,32 @@ function Builders.single_y_pattern(shape, height)
|
||||
end
|
||||
end
|
||||
|
||||
function Builders.grid_x_pattern(pattern, columns, width)
|
||||
local half_width = width / 2
|
||||
|
||||
return function(x, y, world)
|
||||
local x2 = ((x + half_width) % width) - half_width
|
||||
local columns_pos = math.floor(x / width + 0.5)
|
||||
local column_i = columns_pos % columns + 1
|
||||
local shape = pattern[column_i] or Builders.empty_shape
|
||||
|
||||
return shape(x2, y, world)
|
||||
end
|
||||
end
|
||||
|
||||
function Builders.grid_y_pattern(pattern, rows, height)
|
||||
local half_height = height / 2
|
||||
|
||||
return function(x, y, world)
|
||||
local y2 = ((y + half_height) % height) - half_height
|
||||
local row_pos = math.floor(y / height + 0.5)
|
||||
local row_i = row_pos % rows + 1
|
||||
local shape = pattern[row_i] or Builders.empty_shape
|
||||
|
||||
return shape(x, y2, world)
|
||||
end
|
||||
end
|
||||
|
||||
function Builders.grid_pattern(pattern, columns, rows, width, height)
|
||||
local half_width = width / 2
|
||||
local half_height = height / 2
|
||||
|
@ -67,6 +67,7 @@ local tiles_per_tick = 32
|
||||
--shape = require "map_gen.presets.factory"
|
||||
--shape = require "map_gen.presets.triangle_of_death"
|
||||
--shape = require "map_gen.presets.world_map"
|
||||
shape = require "map_gen.presets.lines_and_squares"
|
||||
--shape = require "map_gen.presets.test"
|
||||
|
||||
--shapes--
|
||||
@ -136,6 +137,6 @@ if shape then
|
||||
['nauvis'] = shape,
|
||||
}
|
||||
|
||||
require('map_gen.shared.generate')({surfaces = surfaces, regen_decoratives = regen_decoratives, tiles_per_tick = tiles_per_tick})
|
||||
--require ("map_gen.shared.generate_not_threaded")({surfaces = surfaces, regen_decoratives = regen_decoratives})
|
||||
--require('map_gen.shared.generate')({surfaces = surfaces, regen_decoratives = regen_decoratives, tiles_per_tick = tiles_per_tick})
|
||||
require ("map_gen.shared.generate_not_threaded")({surfaces = surfaces, regen_decoratives = regen_decoratives})
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user