mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
imported nekos stuff and changed map layout
This commit is contained in:
parent
5e6435674d
commit
82e63561d0
57
locale/map_generation/gen_resources/neko_crazy_ores.lua
Normal file
57
locale/map_generation/gen_resources/neko_crazy_ores.lua
Normal file
@ -0,0 +1,57 @@
|
||||
if ores_module then return end
|
||||
ores_module = true
|
||||
|
||||
local random_ores = {"iron-ore","coal","copper-ore","stone","uranium-ore"}
|
||||
local random_dense = {1.15,0.8,1,0.9, 0.5} --ore density reference
|
||||
|
||||
function run_ores_module(event)
|
||||
--game.print("gen crazy ores")
|
||||
if not global.ores_seed_A then global.ores_seed_A = math.random(10,10000) end
|
||||
if not global.ores_seed_B then global.ores_seed_B = math.random(10,10000) end
|
||||
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
|
||||
local entities = surface.find_entities(area)
|
||||
for _, entity in pairs(entities) do
|
||||
if entity.type == "resource" then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
top_left = area.left_top --make a more direct reference
|
||||
|
||||
local distance_bonus = 200 + math.sqrt(top_left.x*top_left.x + top_left.y*top_left.y) * 0.2
|
||||
|
||||
for x = area.left_top.x, area.right_bottom.x do
|
||||
for y = area.left_top.y, area.right_bottom.y do
|
||||
--table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
|
||||
local wiggle = 100 + perlin:noise((x*0.005),(y*0.005),global.ores_seed_A + 41) * 60
|
||||
local Ores_A = perlin:noise((x*0.01),(y*0.01),global.ores_seed_B + 57) * wiggle
|
||||
|
||||
|
||||
if Ores_A > 35 then --we place ores
|
||||
local Ores_B = perlin:noise((x*0.02),(y*0.02),global.ores_seed_B + 13) * wiggle
|
||||
local a = 5
|
||||
--
|
||||
if Ores_A < 76 then a = math.floor(Ores_A*0.75 + Ores_B*0.5) % 4 + 1 end --if its not super high we place normal ores
|
||||
--
|
||||
local res_amount = distance_bonus
|
||||
res_amount = math.floor(res_amount * random_dense[a])
|
||||
--
|
||||
if surface.can_place_entity {name=random_ores[a], position={x,y}} then
|
||||
surface.create_entity {name=random_ores[a], position={x,y}, amount=res_amount}
|
||||
end
|
||||
elseif Ores_A < -60 then
|
||||
if math.random(1,200) == 1 and surface.can_place_entity {name="crude-oil", position={x,y}} then
|
||||
surface.create_entity {name="crude-oil", position={x,y}, amount = math.random(20000,60000) +distance_bonus* 2000 }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
20
locale/map_generation/gen_shape/right.lua
Normal file
20
locale/map_generation/gen_shape/right.lua
Normal file
@ -0,0 +1,20 @@
|
||||
if shape_module then return end
|
||||
shape_module = true
|
||||
|
||||
function run_shape_module(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
if area.left_top.x < -75 or area.left_top.y > 32 or area.left_top.y < -400 then
|
||||
for x = area.left_top.x, area.right_bottom.x do
|
||||
for y = area.left_top.y, area.right_bottom.y do
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
19
locale/map_generation/gen_shape/up.lua
Normal file
19
locale/map_generation/gen_shape/up.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local module = {}
|
||||
|
||||
function module.on_chunk_generated(event)
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
if area.left_top.y > 50 or area.left_top.x > 96 or area.left_top.x < -128 then
|
||||
for x = area.left_top.x, area.right_bottom.x do
|
||||
for y = area.left_top.y, area.right_bottom.y do
|
||||
table.insert(tiles, {name = "out-of-map", position = {x,y}})
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return module
|
535
locale/map_generation/gen_shared/ent_functions.lua
Normal file
535
locale/map_generation/gen_shared/ent_functions.lua
Normal file
@ -0,0 +1,535 @@
|
||||
--allows any gen to access these functions
|
||||
|
||||
function place_entities(surface, entity_list)
|
||||
local directions = {defines.direction.north, defines.direction.east, defines.direction.south, defines.direction.west}
|
||||
for _, entity in pairs(entity_list) do
|
||||
local r = math.random(1,entity.chance)
|
||||
if r == 1 then
|
||||
if not entity.force then entity.force = "player" end
|
||||
local r = math.random(1,4)
|
||||
if surface.can_place_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force} then
|
||||
local e = surface.create_entity {name=entity.name, position=entity.pos, direction=directions[r], force=entity.force}
|
||||
if entity.health then
|
||||
if entity.health == "low" then e.health = ((e.health / 1000) * math.random(33,330)) end
|
||||
if entity.health == "medium" then e.health = ((e.health / 1000) * math.random(333,666)) end
|
||||
if entity.health == "high" then e.health = ((e.health / 1000) * math.random(666,999)) end
|
||||
if entity.health == "random" then e.health = ((e.health / 1000) * math.random(1,1000)) end
|
||||
end
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function auto_place_entity_around_target(entity, scan_radius, mode, density, surface)
|
||||
local x = entity.pos.x
|
||||
local y = entity.pos.y
|
||||
if not surface then surface = game.surfaces[1] end
|
||||
if not scan_radius then scan_radius = 6 end
|
||||
if not entity then return end
|
||||
if not mode then mode = "ball" end
|
||||
if not density then density = 1 end
|
||||
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
|
||||
local i = 2
|
||||
local r = 1
|
||||
|
||||
if mode == "ball" then
|
||||
if math.random(1,2) == 1 then
|
||||
density = density * -1
|
||||
end
|
||||
r = math.random(1,4)
|
||||
end
|
||||
if mode == "line" then
|
||||
density = 1
|
||||
r = math.random(1,4)
|
||||
end
|
||||
if mode == "line_down" then
|
||||
density = density * -1
|
||||
r = math.random(1,4)
|
||||
end
|
||||
if mode == "line_up" then
|
||||
density = 1
|
||||
r = math.random(1,4)
|
||||
end
|
||||
if mode == "block" then
|
||||
r = 1
|
||||
density = 1
|
||||
end
|
||||
|
||||
if r == 1 then
|
||||
--start placing at -1,-1
|
||||
while i <= scan_radius do
|
||||
y = y - density
|
||||
x = x - density
|
||||
for a = 1, i, 1 do
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
x = x + density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
y = y + density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
x = x - density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
y = y - density
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
end
|
||||
|
||||
if r == 2 then
|
||||
--start placing at 0,-1
|
||||
while i <= scan_radius do
|
||||
y = y - density
|
||||
x = x - density
|
||||
for a = 1, i, 1 do
|
||||
x = x + density
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
y = y + density
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
x = x - density
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
y = y - density
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
end
|
||||
|
||||
if r == 3 then
|
||||
--start placing at 1,-1
|
||||
while i <= scan_radius do
|
||||
y = y - density
|
||||
x = x + density
|
||||
for a = 1, i, 1 do
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
y = y + density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
x = x - density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
y = y - density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
x = x + density
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
end
|
||||
|
||||
if r == 4 then
|
||||
--start placing at 1,0
|
||||
while i <= scan_radius do
|
||||
y = y - density
|
||||
x = x + density
|
||||
for a = 1, i, 1 do
|
||||
y = y + density
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
x = x - density
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
y = y - density
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
x = x + density
|
||||
if surface.can_place_entity {name=entity.name, position={x,y}} then
|
||||
local e = surface.create_entity {name=entity.name, position={x,y}}
|
||||
return true, e
|
||||
end
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function create_entitie_cluster(name, pos, amount)
|
||||
|
||||
local surface = game.surfaces[1]
|
||||
local entity = {}
|
||||
entity.pos = pos
|
||||
entity.name = name
|
||||
local mode = "ball"
|
||||
|
||||
for i = 1, amount, 1 do
|
||||
local b, e = auto_place_entity_around_target(entity, 30, mode)
|
||||
if b == true then
|
||||
if 1 == math.random(1,40) then
|
||||
entity.pos = e.position
|
||||
end
|
||||
if e.type == "resource" then
|
||||
e.amount = math.random(500,1500)
|
||||
end
|
||||
end
|
||||
end
|
||||
return b, e
|
||||
end
|
||||
|
||||
function create_rock_cluster(pos, amount)
|
||||
if not pos then return false end
|
||||
if amount == nil then amount = 7 end
|
||||
local scan_radius = amount * 2
|
||||
local mode = "line_down"
|
||||
if math.random(1,2) == 1 then mode = "line_up" end
|
||||
local entity = {}
|
||||
entity.pos = pos
|
||||
for i = 1, amount, 1 do
|
||||
if 1 == math.random(1,3) then
|
||||
entity.name = "red-desert-rock-huge-01"
|
||||
else
|
||||
entity.name = "red-desert-rock-big-01"
|
||||
end
|
||||
local b, e = auto_place_entity_around_target(entity, scan_radius, mode)
|
||||
if b == true then
|
||||
if 1 ~= math.random(1,20) then
|
||||
entity.pos = e.position
|
||||
end
|
||||
end
|
||||
end
|
||||
return b, e
|
||||
end
|
||||
|
||||
function create_tree_cluster(pos, amount)
|
||||
if not pos then return false end
|
||||
if amount == nil then amount = 7 end
|
||||
local scan_radius = amount * 2
|
||||
--local mode = "line_down"
|
||||
--if math.random(1,2) == 1 then mode = "line_up" end
|
||||
local mode = "ball"
|
||||
local entity = {}
|
||||
entity.pos = pos
|
||||
for i = 1, amount, 1 do
|
||||
entity.name = "tree-06"
|
||||
local density = 2
|
||||
if 1 == math.random(1,20) then entity.name = "tree-07" end
|
||||
if 1 == math.random(1,70) then entity.name = "tree-09" end
|
||||
if 1 == math.random(1,10) then entity.name = "tree-04" end
|
||||
if 1 == math.random(1,9) then density = 1 end
|
||||
if 1 == math.random(1,3) then density = 3 end
|
||||
if 1 == math.random(1,3) then density = 4 end
|
||||
|
||||
local b, e = auto_place_entity_around_target(entity, scan_radius, mode, density)
|
||||
if b == true then
|
||||
if 1 == math.random(1,3) then
|
||||
entity.pos = e.position
|
||||
end
|
||||
end
|
||||
end
|
||||
return b, e
|
||||
end
|
||||
|
||||
function find_tile_placement_spot_around_target_position(tilename, position, mode, density)
|
||||
local x = position.x
|
||||
local y = position.y
|
||||
if not surface then surface = game.surfaces[1] end
|
||||
local scan_radius = 50
|
||||
if not tilename then return end
|
||||
if not mode then mode = "ball" end
|
||||
if not density then density = 1 end
|
||||
local cluster_tiles = {}
|
||||
local auto_correct = false
|
||||
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,false)
|
||||
return true, x, y
|
||||
end
|
||||
|
||||
local i = 2
|
||||
local r = 1
|
||||
|
||||
if mode == "ball" then
|
||||
if math.random(1,2) == 1 then
|
||||
density = density * -1
|
||||
end
|
||||
r = math.random(1,4)
|
||||
end
|
||||
if mode == "line" then
|
||||
density = 1
|
||||
r = math.random(1,4)
|
||||
end
|
||||
if mode == "line_down" then
|
||||
density = density * -1
|
||||
r = math.random(1,4)
|
||||
end
|
||||
if mode == "line_up" then
|
||||
density = 1
|
||||
r = math.random(1,4)
|
||||
end
|
||||
if mode == "block" then
|
||||
r = 1
|
||||
density = 1
|
||||
end
|
||||
|
||||
if r == 1 then
|
||||
--start placing at -1,-1
|
||||
while i <= scan_radius do
|
||||
y = y - density
|
||||
x = x - density
|
||||
for a = 1, i, 1 do
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
x = x + density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
y = y + density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
x = x - density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
y = y - density
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
end
|
||||
|
||||
if r == 2 then
|
||||
--start placing at 0,-1
|
||||
while i <= scan_radius do
|
||||
y = y - density
|
||||
x = x - density
|
||||
for a = 1, i, 1 do
|
||||
x = x + density
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
y = y + density
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
x = x - density
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
y = y - density
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
end
|
||||
|
||||
if r == 3 then
|
||||
--start placing at 1,-1
|
||||
while i <= scan_radius do
|
||||
y = y - density
|
||||
x = x + density
|
||||
for a = 1, i, 1 do
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
y = y + density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
x = x - density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
y = y - density
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
x = x + density
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
end
|
||||
|
||||
if r == 4 then
|
||||
--start placing at 1,0
|
||||
while i <= scan_radius do
|
||||
y = y - density
|
||||
x = x + density
|
||||
for a = 1, i, 1 do
|
||||
y = y + density
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
x = x - density
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
y = y - density
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
end
|
||||
for a = 1, i, 1 do
|
||||
x = x + density
|
||||
local scanned_tile = surface.get_tile(x,y)
|
||||
if scanned_tile.name ~= tilename then
|
||||
table.insert(cluster_tiles, {name = tilename, position = {x,y}})
|
||||
surface.set_tiles(cluster_tiles,auto_correct)
|
||||
return true, x, y
|
||||
end
|
||||
end
|
||||
i = i + 2
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function create_tile_cluster(tilename,position,amount)
|
||||
local mode = "ball"
|
||||
local cluster_tiles = {}
|
||||
local surface = game.surfaces[1]
|
||||
local pos = position
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
for i = 1, amount, 1 do
|
||||
local b,x,y = find_tile_placement_spot_around_target_position(tilename, pos, mode)
|
||||
if b == true then
|
||||
if 1 == math.random(1,2) then
|
||||
pos.x = x
|
||||
pos.y = y
|
||||
end
|
||||
end
|
||||
if b == false then return false,x,y end
|
||||
if i >= amount then return true,x,y end
|
||||
end
|
||||
end
|
146
locale/map_generation/gen_terrain/neko_bridged_rivers.lua
Normal file
146
locale/map_generation/gen_terrain/neko_bridged_rivers.lua
Normal file
@ -0,0 +1,146 @@
|
||||
if terrain_module then return end
|
||||
terrain_module = true
|
||||
|
||||
local tree_to_place = {"dry-tree","dry-hairy-tree","tree-06","tree-06","tree-01","tree-02","tree-03"}
|
||||
|
||||
function run_terrain_module(event)
|
||||
if not global.terrain_seed_A then global.terrain_seed_A = math.random(10,10000) end
|
||||
if not global.terrain_seed_B then global.terrain_seed_B = math.random(10,10000) end
|
||||
|
||||
local area = event.area
|
||||
local surface = event.surface
|
||||
local tiles = {}
|
||||
|
||||
|
||||
local entities = surface.find_entities(area)
|
||||
for _, entity in pairs(entities) do
|
||||
--if entity.type == "simple-entity" or entity.type == "resource" or entity.type == "tree" then
|
||||
if entity.type == "simple-entity" or entity.type == "tree" then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local top_left = area.left_top --make a more direct reference
|
||||
|
||||
--do it only per chunk, cause cheaper than every square, and who care anyway.
|
||||
--local distance_bonus = 200 + math.sqrt(top_left.x*top_left.x + top_left.y*top_left.y) * 0.2
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos_x = top_left.x + x
|
||||
local pos_y = top_left.y + y
|
||||
local tile = surface.get_tile(pos_x,pos_y)
|
||||
local tile_to_insert = "grass-medium"
|
||||
|
||||
local wiggle = 50 + perlin:noise((pos_x*0.005),(pos_y*0.005),global.terrain_seed_A + 71) * 60
|
||||
local terrain_A = perlin:noise((pos_x*0.005),(pos_y*0.005),global.terrain_seed_A + 19) * wiggle --For determining where water is
|
||||
local terrain_sqr = terrain_A * terrain_A --we can use this again to mess with other layers as well
|
||||
local terrain_D = 10 + perlin:noise((pos_x*0.001),(pos_y*0.001),global.terrain_seed_A + 5) * wiggle --terrain layer
|
||||
|
||||
if terrain_sqr < 50 then --Main water areas
|
||||
--local deep = (terrain_sqr < 20) and true or false
|
||||
terrain_A = perlin:noise((pos_x*0.01),(pos_y*0.01),global.terrain_seed_A + 31) * 90 + (wiggle * -0.2) --we only gen this when we consider placing water
|
||||
|
||||
if terrain_A * terrain_A > 40 then --creates random bridges over the water by overlapping with another noise layer
|
||||
|
||||
tile_to_insert = "water"
|
||||
|
||||
--simpler water fix-not perfect but saves changing extra tiles
|
||||
if x == 0 then table.insert(tiles, {name = tile_to_insert, position = {pos_x-1,pos_y}})end
|
||||
if x == 31 then table.insert(tiles, {name = tile_to_insert, position = {pos_x+1,pos_y}})end
|
||||
if y == 0 then table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y-1}})end
|
||||
if y == 31 then table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y+1}})end
|
||||
else
|
||||
if terrain_D >= 20 then tile_to_insert = "sand" end
|
||||
end
|
||||
elseif terrain_sqr > 80 then
|
||||
wiggle = 100 + perlin:noise((pos_x*0.005),(pos_y*0.005),global.terrain_seed_B + 41) * 60
|
||||
--local terrain_B = perlin:noise((pos_x*0.01),(pos_y*0.01),global.terrain_seed_B + 57) * wiggle --ores layer
|
||||
local terrain_C = perlin:noise((pos_x*0.02),(pos_y*0.02),global.terrain_seed_A + 13) * wiggle --tree layer
|
||||
|
||||
--if terrain_B > 35 then --we place ores
|
||||
-- local a = 5
|
||||
--
|
||||
-- if terrain_B < 76 then a = math.floor(terrain_B*0.75 + terrain_C*0.5) % 4 + 1 end --if its not super high we place normal ores
|
||||
--
|
||||
-- local res_amount = distance_bonus + terrain_sqr * 0.1
|
||||
-- res_amount = math.floor(res_amount * random_dense[a])
|
||||
--
|
||||
-- if surface.can_place_entity {name=random_ores[a], position={pos_x,pos_y}} then
|
||||
-- surface.create_entity {name=random_ores[a], position={pos_x,pos_y}, amount=res_amount}
|
||||
-- end
|
||||
--end
|
||||
|
||||
--wiggle = 100 + perlin:noise((pos_x*0.02),(pos_y*0.02),global.terrain_seed_B + 71) * 60
|
||||
|
||||
|
||||
if terrain_D < 20 then
|
||||
|
||||
|
||||
if terrain_C < 4 then --we set grass around near forest areas
|
||||
|
||||
tile_to_insert = "grass"
|
||||
|
||||
if terrain_C < -20 and math.random(1,3) == 1 then --dense trees
|
||||
local treenum = math.random(3,7)
|
||||
if surface.can_place_entity {name=tree_to_place[treenum], position={pos_x,pos_y}} then
|
||||
surface.create_entity {name=tree_to_place[treenum], position={pos_x,pos_y}}
|
||||
end
|
||||
else
|
||||
if terrain_C < 0 and math.random(1,7) == 1 then --less dense trees
|
||||
local treenum = math.random(3,5)
|
||||
if surface.can_place_entity {name=tree_to_place[treenum], position={pos_x,pos_y}} then
|
||||
surface.create_entity {name=tree_to_place[treenum], position={pos_x,pos_y}}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if terrain_D < 30 then
|
||||
tile_to_insert = "sand"
|
||||
|
||||
if terrain_C < -20 and math.random(1,7) == 1 then --dense trees
|
||||
local treenum = math.random(1,3)
|
||||
if surface.can_place_entity {name=tree_to_place[treenum], position={pos_x,pos_y}} then
|
||||
surface.create_entity {name=tree_to_place[treenum], position={pos_x,pos_y}}
|
||||
end
|
||||
elseif terrain_C < 0 and math.random(1,13) == 1 then --less dense trees
|
||||
local treenum = math.random(1,2)
|
||||
if surface.can_place_entity {name=tree_to_place[treenum], position={pos_x,pos_y}} then
|
||||
surface.create_entity {name=tree_to_place[treenum], position={pos_x,pos_y}}
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
tile_to_insert = "sand-dark"
|
||||
--if terrain_C > 40 and math.random(1,200) == 1 and surface.can_place_entity {name="crude-oil", position={pos_x,pos_y}} then
|
||||
-- surface.create_entity {name="crude-oil", position={pos_x,pos_y}, amount = math.random(20000,60000) +distance_bonus* 2000 }
|
||||
--end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if math.floor(terrain_D) % 5 == 1 and math.random(1,70) == 1 and surface.can_place_entity {name="stone-rock", position={pos_x,pos_y}} then
|
||||
surface.create_entity {name="stone-rock", position={pos_x,pos_y}}
|
||||
end
|
||||
|
||||
else
|
||||
if terrain_D >= 20 then
|
||||
if terrain_D < 30 then
|
||||
tile_to_insert = "sand"
|
||||
else
|
||||
tile_to_insert = "sand-dark"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})
|
||||
end
|
||||
end
|
||||
--game.print("break end")
|
||||
--game.print(lowest .. " to " .. highest)
|
||||
|
||||
surface.set_tiles(tiles,true)
|
||||
|
||||
end
|
118
map_layout.lua
118
map_layout.lua
@ -16,48 +16,95 @@ To learn how to write a valid style refere to /locale/map_layout/sample.lua
|
||||
require "locale.map_layout.perlin_noise"
|
||||
perlin:load( )
|
||||
|
||||
--TODO: IMPLEMENT BROKEN STYLES. DO NOT MERGE INTO MASTER BEFORE THIS
|
||||
|
||||
local map_shapes = {
|
||||
--Map shapes
|
||||
sample = false,
|
||||
up = true, --broken
|
||||
right = false, --broken
|
||||
square = false, --broken
|
||||
circle = false, --broken
|
||||
}
|
||||
|
||||
|
||||
|
||||
--TODO: IMPLEMENT BROKEN STYLES. DO NOT MERGE INTO MASTER BEFORE THIS IS
|
||||
|
||||
local map_styles = {
|
||||
local terrain_gens = {
|
||||
--Map generation styles:
|
||||
sample = true,
|
||||
rail_grid = true,
|
||||
up = false, --broken
|
||||
right = false, --broken
|
||||
square = false, --broken
|
||||
circle = false, --broken
|
||||
rivers = false, --broken
|
||||
red_planet = false, --broken
|
||||
red_planet_2 = false, --broken
|
||||
red_planet_2_messy_resources = false, --broken
|
||||
dagobah_swamp = false, --broken
|
||||
grey_void = false, --broken
|
||||
perlin_01 = false, --broken
|
||||
perlin_02 = false, --broken
|
||||
perlin_noise = false, --broken
|
||||
gens_neko = false, --broken
|
||||
rivers = false, --broken
|
||||
red_planet = false, --broken
|
||||
red_planet_2 = false, --broken
|
||||
red_planet_2_messy_resources = false, --broken
|
||||
dagobah_swamp = false, --broken
|
||||
grey_void = false, --broken
|
||||
perlin_01 = false, --broken
|
||||
perlin_02 = false, --broken
|
||||
gens_neko = false, --broken
|
||||
}
|
||||
|
||||
local resource_gens = {
|
||||
--resource generation styles:
|
||||
resource_rainbow = false, --broken
|
||||
resource_cluster_truck = false --broken
|
||||
}
|
||||
|
||||
|
||||
--resource generation styles:
|
||||
resource_rainbow = false, --broken
|
||||
resource_cluster_truck = false --broken
|
||||
local entitiy_gens = {
|
||||
rail_grid = false
|
||||
}
|
||||
|
||||
|
||||
local selected_styles = {}
|
||||
local shape_module
|
||||
local terrain_module
|
||||
local ore_module
|
||||
local item_gens
|
||||
|
||||
for name, enabled in pairs(map_styles) do
|
||||
|
||||
local generate_shape = function(event)
|
||||
return true
|
||||
end
|
||||
local generate_terrain = function(event)
|
||||
end
|
||||
local generate_resources = function(event)
|
||||
end
|
||||
local generate_entities = function(event)
|
||||
end
|
||||
|
||||
for name, enabled in pairs(map_shapes) do
|
||||
if enabled then
|
||||
local module = require("locale.map_layout." .. name)
|
||||
local module = require("locale.map_generation.gen_shape." .. name)
|
||||
if type(module) == "boolean" then
|
||||
debug.print("Error loading module ''" .. name .."''. No table containing module elements returned")
|
||||
error("Error loading module ''" .. name .."''. No table containing module elements returned")
|
||||
else
|
||||
table.insert(selected_styles, module)
|
||||
generate_shape = module.on_chunk_generated
|
||||
end
|
||||
end
|
||||
end
|
||||
for name, enabled in pairs(terrain_gens) do
|
||||
if enabled then
|
||||
local module = require("locale.map_generation.gen_terrain." .. name)
|
||||
if type(module) == "boolean" then
|
||||
error("Error loading module ''" .. name .."''. No table containing module elements returned")
|
||||
else
|
||||
generate_terrain = module.on_chunk_generated
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for name, enabled in pairs(resource_gens) do
|
||||
if enabled then
|
||||
local module = require("locale.map_generation.gen_resources." .. name)
|
||||
if type(module) == "boolean" then
|
||||
error("Error loading module ''" .. name .."''. No table containing module elements returned")
|
||||
else
|
||||
generate_resources = module.on_chunk_generated
|
||||
end
|
||||
end
|
||||
end
|
||||
for name, enabled in pairs(entitiy_gens) do
|
||||
if enabled then
|
||||
local module = require("locale.map_generation.gen_entities." .. name)
|
||||
if type(module) == "boolean" then
|
||||
error("Error loading module ''" .. name .."''. No table containing module elements returned")
|
||||
else
|
||||
generate_entities = module.on_chunk_generated
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -65,12 +112,11 @@ end
|
||||
|
||||
|
||||
local on_chunk_generated = function(event)
|
||||
for _, module in pairs(selected_styles) do
|
||||
if type(module) == "table" and type(module.on_chunk_generated) == "function" then
|
||||
module.on_chunk_generated(event)
|
||||
else
|
||||
log("Module does not contain function on_chunk_generated. Check if all enabled styles are valid modules.")
|
||||
end
|
||||
local continue = generate_shape(event)
|
||||
if type(continue) == "nil" or continue then
|
||||
generate_terrain(event)
|
||||
gen_resources(event)
|
||||
generate_entities(event)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user