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

changed perline noise to local

This commit is contained in:
grilledham 2018-05-23 22:34:47 +01:00
parent b356e3ec5e
commit 809f2ffb31
11 changed files with 2501 additions and 2041 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
require "map_gen.shared.perlin_noise"
local Task = require "utils.Task"
local Event = require "utils.event"
local perlin = require 'map_gen.shared.perlin_noise'
local Task = require 'utils.Task'
local Event = require 'utils.event'
local block_size = 1 -- in tiles
local start_size = 64 -- in blocks
@ -8,7 +8,7 @@ local strike_time = 1 -- in ticks
-- dud blocks don't spawn meteors, with a block_weight = 1 and dud weight = 3, every 3 out of 4 blocks will be a dud block
local block_weight = 1
local dud_weight = 0
local dud_weight = 0
local min_blocks_in_list = 10 -- no dud meteors if the number of blocks in the list is less than or equal to this
global.blocks = nil
@ -22,58 +22,55 @@ local total_weight = block_weight + dud_weight
local function init_blocks()
local blocks = {}
local used_blocks = {}
local half = start_size / 2
local half = start_size / 2
for i = -half, half - 1 do
table.insert(blocks,{x = i, y = -half - 1})
used_blocks[i .. "," .. (-half - 1)] = true
table.insert(blocks,{x = i, y = half})
used_blocks[i .. "," .. half] = true
table.insert(blocks,{x = -half - 1, y = i})
used_blocks[(-half - 1) .. "," .. i] = true
table.insert(blocks,{x = half, y = i})
used_blocks[half .. "," .. i] = true
table.insert(blocks, {x = i, y = -half - 1})
used_blocks[i .. ',' .. (-half - 1)] = true
table.insert(blocks, {x = i, y = half})
used_blocks[i .. ',' .. half] = true
table.insert(blocks, {x = -half - 1, y = i})
used_blocks[(-half - 1) .. ',' .. i] = true
table.insert(blocks, {x = half, y = i})
used_blocks[half .. ',' .. i] = true
for j = -half, half -1 do
used_blocks[i .. "," .. j] = true
end
for j = -half, half - 1 do
used_blocks[i .. ',' .. j] = true
end
end
global.blocks = blocks
global.used_blocks = used_blocks
end
local function get_resource(x,y)
local value = perlin:noise(x /16 , y / 16)
local function get_resource(x, y)
local value = perlin:noise(x / 16, y / 16)
value = value + 1
value = value * 500
local name = ""
local name = ''
if value < 450 then
return nil
return nil
elseif value < 550 then
name = "iron-ore"
name = 'iron-ore'
elseif value < 650 then
name = "copper-ore"
name = 'copper-ore'
elseif value < 750 then
name = "coal"
name = 'coal'
elseif value < 850 then
name = "stone"
else
name = 'stone'
else
return nil
end
value = perlin:noise(y /64 , x / 64)
value = perlin:noise(y / 64, x / 64)
value = value + 1
value = value * 500
return {name=name,position={x,y}, amount = value}
return {name = name, position = {x, y}, amount = value}
end
function run_combined_module(event)
if not global.blocks then
init_blocks()
end
@ -81,30 +78,29 @@ function run_combined_module(event)
local area = event.area
local surface = event.surface
local top_x = area.left_top.x
local top_y = area.left_top.y
local top_y = area.left_top.y
local tiles = {}
local entities = {}
local entities = {}
for y = top_y, top_y + 31 do
for x = top_x, top_x + 31 do
for x = top_x, top_x + 31 do
if -x > half_start_size or x >= half_start_size or -y > half_start_size or y >= half_start_size then
table.insert(tiles, {name="out-of-map", position = {x, y}})
table.insert(tiles, {name = 'out-of-map', position = {x, y}})
end
local e = get_resource(x,y)
local e = get_resource(x, y)
if e then
table.insert(entities, e)
end
end
end
surface.set_tiles(tiles, false)
for _, e in ipairs(entities) do
if surface.can_place_entity(e) then
surface.create_entity(e)
surface.create_entity(e)
end
end
end
@ -114,7 +110,7 @@ local function get_block()
local count = global.weight_count
while count >= block_weight and count < total_weight and #blocks > min_blocks_in_list do
local index = math.random(#blocks)
table.remove(blocks, index)
table.remove(blocks, index)
count = count + 1
end
@ -122,54 +118,54 @@ local function get_block()
count = count + 1
end
if count == total_weight then
if count == total_weight then
global.weight_count = 0
else
global.weight_count = count
end
local index = math.random(#blocks)
return table.remove(blocks, index)
return table.remove(blocks, index)
end
local function do_strike()
local block = get_block()
local function do_strike()
local block = get_block()
function add(x,y)
local key = x .. "," .. y
function add(x, y)
local key = x .. ',' .. y
if not global.used_blocks[key] then
table.insert(global.blocks, {x = x, y = y})
global.used_blocks[key] = true
global.used_blocks[key] = true
end
end
add(block.x, block.y - 1)
add(block.x + 1, block.y)
add(block.x, block.y + 1)
add(block.x - 1, block.y)
add(block.x - 1, block.y)
local tiles = {}
local bx = block.x * block_size
local by = block.y * block_size
local by = block.y * block_size
for x = bx, bx + block_size - 1 do
for y = by, by + block_size - 1 do
table.insert(tiles, {name = "dry-dirt", position = {x, y}})
table.insert(tiles, {name = 'dry-dirt', position = {x, y}})
end
end
local surface = game.surfaces[1]
surface.set_tiles(tiles, false)
game.forces.player.chart(surface, {{bx, by}, {bx+block_size, by+block_size}})
game.forces.player.chart(surface, {{bx, by}, {bx + block_size, by + block_size}})
end
local function on_tick()
local function on_tick()
if global.strike_time == 0 then
do_strike()
global.strike_time = strike_time
else
else
global.strike_time = global.strike_time - 1
end
end
Event.add(defines.events.on_tick, on_tick)
Event.add(defines.events.on_tick, on_tick)

View File

@ -3,368 +3,530 @@
-- !! ATTENTION !!
-- Use water only in starting area as map setting!!!
require "map_gen.shared.perlin_noise"
local Task = require "utils.Task"
local perlin = require 'map_gen.shared.perlin_noise'
local Task = require 'utils.Task'
wreck_item_pool = {}
wreck_item_pool = {{name="iron-gear-wheel", count=32},{name="iron-plate", count=64},{name="rocket-control-unit", count=1} ,{name="coal", count=4},{name="rocket-launcher", count=1},{name="rocket", count=32},{name="copper-cable", count=128},{name="land-mine", count=64},{name="railgun", count=1},{name="railgun-dart", count=128},{name="fast-inserter", count=8},{name="stack-filter-inserter", count=2},{name="belt-immunity-equipment", count=1},{name="fusion-reactor-equipment", count=1},{name="electric-engine-unit", count=8},{name="exoskeleton-equipment", count=1},{name="rocket-fuel", count=10},{name="used-up-uranium-fuel-cell", count=3},{name="uranium-fuel-cell", count=2}}
wreck_item_pool = {
{name = 'iron-gear-wheel', count = 32},
{name = 'iron-plate', count = 64},
{name = 'rocket-control-unit', count = 1},
{name = 'coal', count = 4},
{name = 'rocket-launcher', count = 1},
{name = 'rocket', count = 32},
{name = 'copper-cable', count = 128},
{name = 'land-mine', count = 64},
{name = 'railgun', count = 1},
{name = 'railgun-dart', count = 128},
{name = 'fast-inserter', count = 8},
{name = 'stack-filter-inserter', count = 2},
{name = 'belt-immunity-equipment', count = 1},
{name = 'fusion-reactor-equipment', count = 1},
{name = 'electric-engine-unit', count = 8},
{name = 'exoskeleton-equipment', count = 1},
{name = 'rocket-fuel', count = 10},
{name = 'used-up-uranium-fuel-cell', count = 3},
{name = 'uranium-fuel-cell', count = 2}
}
local 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
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
local c = 0.5
local resource_amount_distance_multiplicator = (((c + 1) / 75) / 75) + 1
function run_combined_module(event)
if not global.perlin_noise_seed then global.perlin_noise_seed = math.random(1000,1000000) end
local surface = game.surfaces[1]
if not global.perlin_noise_seed then
global.perlin_noise_seed = math.random(1000, 1000000)
end
local surface = game.surfaces[1]
local entities = surface.find_entities(event.area)
for _, entity in pairs(entities) do
if entity.type == "simple-entity" or entity.type == "resource" or entity.type == "tree" then
entity.destroy()
end
end
Task.queue_task("run_planet_init", {} )
--run_planet_init()
for x = 0, 31, 1 do
Task.queue_task("run_planet", {area = event.area, surface = event.surface, x = x})
--run_planet( {area = event.area, surface = event.surface, x = x})
end
--run_planet_place_tiles( {surface = event.surface} )
Task.queue_task("run_planet_place_tiles", {surface = event.surface})
local entities = surface.find_entities(event.area)
for _, entity in pairs(entities) do
if entity.type == 'simple-entity' or entity.type == 'resource' or entity.type == 'tree' then
entity.destroy()
end
end
Task.queue_task('run_planet_init', {})
--run_planet_init()
for x = 0, 31, 1 do
Task.queue_task('run_planet', {area = event.area, surface = event.surface, x = x})
--run_planet( {area = event.area, surface = event.surface, x = x})
end
--run_planet_place_tiles( {surface = event.surface} )
Task.queue_task('run_planet_place_tiles', {surface = event.surface})
end
global.planet_tiles_hold = {}
global.planet_decoratives_hold = {}
function run_planet_init(params)
global.planet_tiles_hold = {}
global.planet_decoratives_hold = {}
global.planet_tiles_hold = {}
global.planet_decoratives_hold = {}
end
function run_planet_place_tiles(params)
local surface = params.surface
surface.set_tiles(global.planet_tiles_hold)
for _,deco in pairs(global.planet_decoratives_hold) do
surface.create_decoratives{check_collision=false, decoratives={deco}}
end
local surface = params.surface
surface.set_tiles(global.planet_tiles_hold)
for _, deco in pairs(global.planet_decoratives_hold) do
surface.create_decoratives {check_collision = false, decoratives = {deco}}
end
end
function run_planet( params )
local tree_to_place = {"dry-tree","dry-hairy-tree","tree-06","tree-06","tree-01","tree-02","tree-03"}
local area = params.area
local surface = params.surface
function run_planet(params)
local tree_to_place = {'dry-tree', 'dry-hairy-tree', 'tree-06', 'tree-06', 'tree-01', 'tree-02', 'tree-03'}
local area = params.area
local surface = params.surface
local x = params.x
local pos_x = area.left_top.x + x
local x = params.x
local pos_x = area.left_top.x + x
for y = 0, 31, 1 do
local pos_y = area.left_top.y + y
local seed = surface.map_gen_settings.seed
local tile = surface.get_tile(pos_x,pos_y)
local tile_to_insert = "concrete"
for y = 0, 31, 1 do
local pos_y = area.left_top.y + y
local seed = surface.map_gen_settings.seed
local tile = surface.get_tile(pos_x, pos_y)
local tile_to_insert = 'concrete'
local a = pos_x
local b = pos_y
local resource_entity_placed = false
local a = pos_x
local b = pos_y
local resource_entity_placed = false
local entity_list = {}
table.insert(entity_list, {name="big-ship-wreck-1", pos={pos_x,pos_y},chance = 65000, health="random"})
table.insert(entity_list, {name="big-ship-wreck-2", pos={pos_x,pos_y},chance = 65000, health="random"})
table.insert(entity_list, {name="big-ship-wreck-3", pos={pos_x,pos_y},chance = 65000, health="random"})
table.insert(entity_list, {name="medium-ship-wreck", pos={pos_x,pos_y},chance = 25000, health="medium"})
table.insert(entity_list, {name="small-ship-wreck", pos={pos_x,pos_y},chance = 15000, health="medium"})
table.insert(entity_list, {name="car", pos={pos_x,pos_y},chance = 150000, health="low"})
table.insert(entity_list, {name="laser-turret", pos={pos_x,pos_y},chance = 100000, force="enemy", health="low"})
table.insert(entity_list, {name="nuclear-reactor", pos={pos_x,pos_y},chance = 1000000, force="enemy", health="medium"})
local b, placed_entity = place_entities(surface, entity_list)
if b == true then
if placed_entity.name == "big-ship-wreck-1" or placed_entity.name == "big-ship-wreck-2" or placed_entity.name == "big-ship-wreck-3" then
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
placed_entity.insert(wreck_item_pool[math.random(1,#wreck_item_pool)])
end
end
local entity_list = {}
table.insert(entity_list, {name = 'big-ship-wreck-1', pos = {pos_x, pos_y}, chance = 65000, health = 'random'})
table.insert(entity_list, {name = 'big-ship-wreck-2', pos = {pos_x, pos_y}, chance = 65000, health = 'random'})
table.insert(entity_list, {name = 'big-ship-wreck-3', pos = {pos_x, pos_y}, chance = 65000, health = 'random'})
table.insert(entity_list, {name = 'medium-ship-wreck', pos = {pos_x, pos_y}, chance = 25000, health = 'medium'})
table.insert(entity_list, {name = 'small-ship-wreck', pos = {pos_x, pos_y}, chance = 15000, health = 'medium'})
table.insert(entity_list, {name = 'car', pos = {pos_x, pos_y}, chance = 150000, health = 'low'})
table.insert(
entity_list,
{name = 'laser-turret', pos = {pos_x, pos_y}, chance = 100000, force = 'enemy', health = 'low'}
)
table.insert(
entity_list,
{name = 'nuclear-reactor', pos = {pos_x, pos_y}, chance = 1000000, force = 'enemy', health = 'medium'}
)
local b, placed_entity = place_entities(surface, entity_list)
if b == true then
if
placed_entity.name == 'big-ship-wreck-1' or placed_entity.name == 'big-ship-wreck-2' or
placed_entity.name == 'big-ship-wreck-3'
then
placed_entity.insert(wreck_item_pool[math.random(1, #wreck_item_pool)])
placed_entity.insert(wreck_item_pool[math.random(1, #wreck_item_pool)])
placed_entity.insert(wreck_item_pool[math.random(1, #wreck_item_pool)])
end
end
local seed_increment_number = 10000
local seed_increment_number = 10000
local noise_terrain_1 = perlin:noise(((pos_x+seed)/400),((pos_y+seed)/400),0)
noise_terrain_1 = noise_terrain_1 * 100
seed = seed + seed_increment_number
local noise_terrain_2 = perlin:noise(((pos_x+seed)/250),((pos_y+seed)/250),0)
noise_terrain_2 = noise_terrain_2 * 100
seed = seed + seed_increment_number
local noise_terrain_3 = perlin:noise(((pos_x+seed)/100),((pos_y+seed)/100),0)
noise_terrain_3 = noise_terrain_3 * 50
seed = seed + seed_increment_number
local noise_terrain_4 = perlin:noise(((pos_x+seed)/20),((pos_y+seed)/20),0)
noise_terrain_4 = noise_terrain_4 * 10
seed = seed + seed_increment_number
local noise_terrain_5 = perlin:noise(((pos_x+seed)/5),((pos_y+seed)/5),0)
noise_terrain_5 = noise_terrain_5 * 4
seed = seed + seed_increment_number
local noise_sand = perlin:noise(((pos_x+seed)/18),((pos_y+seed)/18),0)
noise_sand = noise_sand * 10
local noise_terrain_1 = perlin:noise(((pos_x + seed) / 400), ((pos_y + seed) / 400), 0)
noise_terrain_1 = noise_terrain_1 * 100
seed = seed + seed_increment_number
local noise_terrain_2 = perlin:noise(((pos_x + seed) / 250), ((pos_y + seed) / 250), 0)
noise_terrain_2 = noise_terrain_2 * 100
seed = seed + seed_increment_number
local noise_terrain_3 = perlin:noise(((pos_x + seed) / 100), ((pos_y + seed) / 100), 0)
noise_terrain_3 = noise_terrain_3 * 50
seed = seed + seed_increment_number
local noise_terrain_4 = perlin:noise(((pos_x + seed) / 20), ((pos_y + seed) / 20), 0)
noise_terrain_4 = noise_terrain_4 * 10
seed = seed + seed_increment_number
local noise_terrain_5 = perlin:noise(((pos_x + seed) / 5), ((pos_y + seed) / 5), 0)
noise_terrain_5 = noise_terrain_5 * 4
seed = seed + seed_increment_number
local noise_sand = perlin:noise(((pos_x + seed) / 18), ((pos_y + seed) / 18), 0)
noise_sand = noise_sand * 10
--DECORATIVES
seed = seed + seed_increment_number
local noise_decoratives_1 = perlin:noise(((pos_x+seed)/20),((pos_y+seed)/20),0)
noise_decoratives_1 = noise_decoratives_1
seed = seed + seed_increment_number
local noise_decoratives_2 = perlin:noise(((pos_x+seed)/30),((pos_y+seed)/30),0)
noise_decoratives_2 = noise_decoratives_2
seed = seed + seed_increment_number
local noise_decoratives_3 = perlin:noise(((pos_x+seed)/30),((pos_y+seed)/30),0)
noise_decoratives_3 = noise_decoratives_3
--DECORATIVES
seed = seed + seed_increment_number
local noise_decoratives_1 = perlin:noise(((pos_x + seed) / 20), ((pos_y + seed) / 20), 0)
noise_decoratives_1 = noise_decoratives_1
seed = seed + seed_increment_number
local noise_decoratives_2 = perlin:noise(((pos_x + seed) / 30), ((pos_y + seed) / 30), 0)
noise_decoratives_2 = noise_decoratives_2
seed = seed + seed_increment_number
local noise_decoratives_3 = perlin:noise(((pos_x + seed) / 30), ((pos_y + seed) / 30), 0)
noise_decoratives_3 = noise_decoratives_3
seed = seed + seed_increment_number
local noise_water_1 = perlin:noise(((pos_x + seed) / 250), ((pos_y + seed) / 300), 0)
noise_water_1 = noise_water_1 * 100
seed = seed + seed_increment_number
local noise_water_2 = perlin:noise(((pos_x + seed) / 100), ((pos_y + seed) / 150), 0)
noise_water_2 = noise_water_2 * 50
seed = seed + seed_increment_number
local noise_water_1 = perlin:noise(((pos_x+seed)/250),((pos_y+seed)/300),0)
noise_water_1 = noise_water_1 * 100
seed = seed + seed_increment_number
local noise_water_2 = perlin:noise(((pos_x+seed)/100),((pos_y+seed)/150),0)
noise_water_2 = noise_water_2 * 50
--RESOURCES
seed = seed + seed_increment_number
local noise_resources = perlin:noise(((pos_x + seed) / 100), ((pos_y + seed) / 100), 0)
seed = seed + seed_increment_number
local noise_resources_2 = perlin:noise(((pos_x + seed) / 40), ((pos_y + seed) / 40), 0)
seed = seed + seed_increment_number
local noise_resources_3 = perlin:noise(((pos_x + seed) / 20), ((pos_y + seed) / 20), 0)
noise_resources = noise_resources * 50 + noise_resources_2 * 20 + noise_resources_3 * 20
noise_resources = noise_resources_2 * 100
--RESOURCES
seed = seed + seed_increment_number
local noise_resources = perlin:noise(((pos_x+seed)/100),((pos_y+seed)/100),0)
seed = seed + seed_increment_number
local noise_resources_2 = perlin:noise(((pos_x+seed)/40),((pos_y+seed)/40),0)
seed = seed + seed_increment_number
local noise_resources_3 = perlin:noise(((pos_x+seed)/20),((pos_y+seed)/20),0)
noise_resources = noise_resources * 50 + noise_resources_2 * 20 + noise_resources_3 * 20
noise_resources = noise_resources_2 * 100
seed = seed + seed_increment_number
local noise_resource_amount_modifier = perlin:noise(((pos_x + seed) / 200), ((pos_y + seed) / 200), 0)
local resource_amount =
1 + ((400 + (400 * noise_resource_amount_modifier * 0.2)) * resource_amount_distance_multiplicator)
seed = seed + seed_increment_number
local noise_resources_iron_and_copper = perlin:noise(((pos_x + seed) / 250), ((pos_y + seed) / 250), 0)
noise_resources_iron_and_copper = noise_resources_iron_and_copper * 100
seed = seed + seed_increment_number
local noise_resources_coal_and_uranium = perlin:noise(((pos_x + seed) / 250), ((pos_y + seed) / 250), 0)
noise_resources_coal_and_uranium = noise_resources_coal_and_uranium * 100
seed = seed + seed_increment_number
local noise_resources_stone_and_oil = perlin:noise(((pos_x + seed) / 150), ((pos_y + seed) / 150), 0)
noise_resources_stone_and_oil = noise_resources_stone_and_oil * 100
seed = seed + seed_increment_number
local noise_resource_amount_modifier = perlin:noise(((pos_x+seed)/200),((pos_y+seed)/200),0)
local resource_amount = 1 + ((400 + (400*noise_resource_amount_modifier*0.2)) * resource_amount_distance_multiplicator)
seed = seed + seed_increment_number
local noise_resources_iron_and_copper = perlin:noise(((pos_x+seed)/250),((pos_y+seed)/250),0)
noise_resources_iron_and_copper = noise_resources_iron_and_copper * 100
seed = seed + seed_increment_number
local noise_resources_coal_and_uranium = perlin:noise(((pos_x+seed)/250),((pos_y+seed)/250),0)
noise_resources_coal_and_uranium = noise_resources_coal_and_uranium * 100
seed = seed + seed_increment_number
local noise_resources_stone_and_oil = perlin:noise(((pos_x+seed)/150),((pos_y+seed)/150),0)
noise_resources_stone_and_oil = noise_resources_stone_and_oil * 100
seed = seed + seed_increment_number
local noise_red_desert_rocks_1 = perlin:noise(((pos_x + seed) / 20), ((pos_y + seed) / 20), 0)
noise_red_desert_rocks_1 = noise_red_desert_rocks_1 * 100
seed = seed + seed_increment_number
local noise_red_desert_rocks_2 = perlin:noise(((pos_x + seed) / 10), ((pos_y + seed) / 10), 0)
noise_red_desert_rocks_2 = noise_red_desert_rocks_2 * 50
seed = seed + seed_increment_number
local noise_red_desert_rocks_3 = perlin:noise(((pos_x + seed) / 5), ((pos_y + seed) / 5), 0)
noise_red_desert_rocks_3 = noise_red_desert_rocks_3 * 100
seed = seed + seed_increment_number
local noise_forest = perlin:noise(((pos_x + seed) / 100), ((pos_y + seed) / 100), 0)
noise_forest = noise_forest * 100
seed = seed + seed_increment_number
local noise_forest_2 = perlin:noise(((pos_x + seed) / 20), ((pos_y + seed) / 20), 0)
noise_forest_2 = noise_forest_2 * 20
seed = seed + seed_increment_number
local noise_red_desert_rocks_1 = perlin:noise(((pos_x+seed)/20),((pos_y+seed)/20),0)
noise_red_desert_rocks_1 = noise_red_desert_rocks_1 * 100
seed = seed + seed_increment_number
local noise_red_desert_rocks_2 = perlin:noise(((pos_x+seed)/10),((pos_y+seed)/10),0)
noise_red_desert_rocks_2 = noise_red_desert_rocks_2 * 50
seed = seed + seed_increment_number
local noise_red_desert_rocks_3 = perlin:noise(((pos_x+seed)/5),((pos_y+seed)/5),0)
noise_red_desert_rocks_3 = noise_red_desert_rocks_3 * 100
seed = seed + seed_increment_number
local noise_forest = perlin:noise(((pos_x+seed)/100),((pos_y+seed)/100),0)
noise_forest = noise_forest * 100
seed = seed + seed_increment_number
local noise_forest_2 = perlin:noise(((pos_x+seed)/20),((pos_y+seed)/20),0)
noise_forest_2 = noise_forest_2 * 20
local terrain_smoothing = math.random(0, 1)
local place_tree_number
local terrain_smoothing = math.random(0,1)
local place_tree_number
if noise_terrain_1 < 8 + terrain_smoothing + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
tile_to_insert = 'red-desert-1'
if
noise_water_1 + noise_water_2 + noise_sand > -10 and noise_water_1 + noise_water_2 + noise_sand < 25 and
noise_terrain_1 < -52 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5
then
tile_to_insert = 'sand-1'
place_tree_number = math.random(3, #tree_to_place)
else
place_tree_number = math.random(1, (#tree_to_place - 3))
end
if noise_terrain_1 < 8 + terrain_smoothing + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
tile_to_insert = "red-desert-1"
if noise_water_1 + noise_water_2 + noise_sand > -10 and noise_water_1 + noise_water_2 + noise_sand < 25 and noise_terrain_1 < -52 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5 then
tile_to_insert = "sand-1"
place_tree_number = math.random(3,#tree_to_place)
else
place_tree_number = math.random(1,(#tree_to_place - 3))
end
if
noise_water_1 + noise_water_2 > 0 and noise_water_1 + noise_water_2 < 15 and
noise_terrain_1 < -60 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5
then
tile_to_insert = 'water'
local a = pos_x + 1
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {a, pos_y}})
local a = pos_y + 1
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x, a}})
local a = pos_x - 1
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {a, pos_y}})
local a = pos_y - 1
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x, a}})
if noise_water_1 + noise_water_2 < 2 or noise_water_1 + noise_water_2 > 13 then
if math.random(1, 15) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'green-carpet-grass', position = {pos_x, pos_y}, amount = 1}
)
end
end
end
if noise_water_1 + noise_water_2 > 0 and noise_water_1 + noise_water_2 < 15 and noise_terrain_1 < -60 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5 then
tile_to_insert = "water"
local a = pos_x + 1
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {a,pos_y}})
local a = pos_y + 1
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x,a}})
local a = pos_x - 1
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {a,pos_y}})
local a = pos_y - 1
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x,a}})
if noise_water_1 + noise_water_2 < 2 or noise_water_1 + noise_water_2 > 13 then
if math.random(1,15) == 1 then
table.insert(global.planet_decoratives_hold, {name="green-carpet-grass", position={pos_x,pos_y}, amount=1})
end
end
end
if tile_to_insert ~= 'water' then
if
noise_water_1 + noise_water_2 > 16 and noise_water_1 + noise_water_2 < 25 and
noise_terrain_1 < -55 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5
then
if math.random(1, 35) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'brown-carpet-grass', position = {pos_x, pos_y}, amount = 1}
)
end
end
if
noise_water_1 + noise_water_2 > -10 and noise_water_1 + noise_water_2 < -1 and
noise_terrain_1 < -55 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5
then
if math.random(1, 35) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'brown-carpet-grass', position = {pos_x, pos_y}, amount = 1}
)
end
end
if noise_decoratives_1 > 0.5 and noise_decoratives_1 <= 0.8 then
if math.random(1, 12) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'red-desert-bush', position = {pos_x, pos_y}, amount = 1}
)
end
end
if noise_decoratives_1 > 0.4 and noise_decoratives_1 <= 0.5 then
if math.random(1, 4) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'red-desert-bush', position = {pos_x, pos_y}, amount = 1}
)
end
end
end
if tile_to_insert ~= "water" then
if noise_water_1 + noise_water_2 > 16 and noise_water_1 + noise_water_2 < 25 and noise_terrain_1 < -55 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5 then
if math.random(1,35) == 1 then
table.insert(global.planet_decoratives_hold, {name="brown-carpet-grass", position={pos_x,pos_y}, amount=1})
end
end
if noise_water_1 + noise_water_2 > -10 and noise_water_1 + noise_water_2 < -1 and noise_terrain_1 < -55 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 + noise_terrain_5 then
if math.random(1,35) == 1 then
table.insert(global.planet_decoratives_hold, {name="brown-carpet-grass", position={pos_x,pos_y}, amount=1})
end
end
if noise_decoratives_1 > 0.5 and noise_decoratives_1 <= 0.8 then
if math.random(1,12) == 1 then table.insert(global.planet_decoratives_hold, {name="red-desert-bush", position={pos_x,pos_y}, amount=1}) end
end
if noise_decoratives_1 > 0.4 and noise_decoratives_1 <= 0.5 then
if math.random(1,4) == 1 then table.insert(global.planet_decoratives_hold, {name="red-desert-bush", position={pos_x,pos_y}, amount=1}) end
end
end
--HAPPY TREES
if noise_terrain_1 < -30 + noise_terrain_2 + noise_terrain_3 + noise_terrain_5 + noise_forest_2 then
if noise_forest > 0 and noise_forest <= 10 then
if math.random(1, 50) == 1 then
if surface.can_place_entity {name = tree_to_place[place_tree_number], position = {pos_x, pos_y}} then
surface.create_entity {name = tree_to_place[place_tree_number], position = {pos_x, pos_y}}
end
end
end
if noise_forest > 10 and noise_forest <= 20 then
if math.random(1, 25) == 1 then
if surface.can_place_entity {name = tree_to_place[place_tree_number], position = {pos_x, pos_y}} then
surface.create_entity {name = tree_to_place[place_tree_number], position = {pos_x, pos_y}}
end
end
end
if noise_forest > 20 then
if math.random(1, 10) == 1 then
if surface.can_place_entity {name = tree_to_place[place_tree_number], position = {pos_x, pos_y}} then
surface.create_entity {name = tree_to_place[place_tree_number], position = {pos_x, pos_y}}
end
end
end
end
--HAPPY TREES
if noise_terrain_1 < -30 + noise_terrain_2 + noise_terrain_3 + noise_terrain_5 + noise_forest_2 then
if noise_forest > 0 and noise_forest <= 10 then
if math.random(1,50) == 1 then
if surface.can_place_entity {name=tree_to_place[place_tree_number], position={pos_x,pos_y}} then
surface.create_entity {name=tree_to_place[place_tree_number], position={pos_x,pos_y}}
end
end
end
if noise_forest > 10 and noise_forest <= 20 then
if math.random(1,25) == 1 then
if surface.can_place_entity {name=tree_to_place[place_tree_number], position={pos_x,pos_y}} then
surface.create_entity {name=tree_to_place[place_tree_number], position={pos_x,pos_y}}
end
end
end
if noise_forest > 20 then
if math.random(1,10) == 1 then
if surface.can_place_entity {name=tree_to_place[place_tree_number], position={pos_x,pos_y}} then
surface.create_entity {name=tree_to_place[place_tree_number], position={pos_x,pos_y}}
end
end
end
end
if tile_to_insert ~= 'water' then
if
noise_terrain_1 < 8 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 and
noise_terrain_1 > -5 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if math.random(1, 180) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'rock-medium', position = {pos_x, pos_y}, amount = 1}
)
end
if math.random(1, 80) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'sand-rock-small', position = {pos_x, pos_y}, amount = 1}
)
end
else
if math.random(1, 1500) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'rock-medium', position = {pos_x, pos_y}, amount = 1}
)
end
if math.random(1, 180) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'sand-rock-small', position = {pos_x, pos_y}, amount = 1}
)
end
end
end
else
tile_to_insert = 'red-desert-0'
end
if
resource_entity_placed == false and noise_resources_coal_and_uranium + noise_resources < -72 and
noise_terrain_1 > 65 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if surface.can_place_entity {name = 'uranium-ore', position = {pos_x, pos_y}} then
surface.create_entity {name = 'uranium-ore', position = {pos_x, pos_y}, amount = resource_amount}
resource_entity_placed = true
end
end
if
resource_entity_placed == false and noise_resources_iron_and_copper + noise_resources > 72 and
noise_terrain_1 > 15 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if surface.can_place_entity {name = 'iron-ore', position = {pos_x, pos_y}} then
surface.create_entity {name = 'iron-ore', position = {pos_x, pos_y}, amount = resource_amount}
resource_entity_placed = true
end
end
if
resource_entity_placed == false and noise_resources_coal_and_uranium + noise_resources > 70 and
noise_terrain_1 > 15 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if surface.can_place_entity {name = 'coal', position = {pos_x, pos_y}} then
surface.create_entity {name = 'coal', position = {pos_x, pos_y}, amount = resource_amount}
resource_entity_placed = true
end
end
if
resource_entity_placed == false and noise_resources_iron_and_copper + noise_resources < -72 and
noise_terrain_1 > 15 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if surface.can_place_entity {name = 'copper-ore', position = {pos_x, pos_y}} then
surface.create_entity {name = 'copper-ore', position = {pos_x, pos_y}, amount = resource_amount}
resource_entity_placed = true
end
end
if
resource_entity_placed == false and noise_resources_stone_and_oil + noise_resources > 72 and
noise_terrain_1 > 15 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if surface.can_place_entity {name = 'stone', position = {pos_x, pos_y}} then
surface.create_entity {name = 'stone', position = {pos_x, pos_y}, amount = resource_amount}
resource_entity_placed = true
end
end
if
resource_entity_placed == false and noise_resources_stone_and_oil + noise_resources < -70 and
noise_terrain_1 < -50 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if math.random(1, 42) == 1 then
if 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 = (resource_amount * 500)
}
resource_entity_placed = true
end
end
end
if tile_to_insert ~= "water" then
if noise_terrain_1 < 8 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 and noise_terrain_1 > -5 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if math.random(1,180) == 1 then
table.insert(global.planet_decoratives_hold, {name="rock-medium", position={pos_x,pos_y}, amount=1})
end
if math.random(1,80) == 1 then
table.insert(global.planet_decoratives_hold, {name="sand-rock-small", position={pos_x,pos_y}, amount=1})
end
else
if math.random(1,1500) == 1 then
table.insert(global.planet_decoratives_hold, {name="rock-medium", position={pos_x,pos_y}, amount=1})
end
if math.random(1,180) == 1 then
table.insert(global.planet_decoratives_hold, {name="sand-rock-small", position={pos_x,pos_y}, amount=1})
end
end
end
else
tile_to_insert = "red-desert-0"
end
if resource_entity_placed == false and noise_resources_coal_and_uranium + noise_resources < -72 and noise_terrain_1 > 65 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if surface.can_place_entity {name="uranium-ore", position={pos_x,pos_y}} then
surface.create_entity {name="uranium-ore", position={pos_x,pos_y}, amount=resource_amount}
resource_entity_placed = true
end
end
if resource_entity_placed == false and noise_resources_iron_and_copper + noise_resources > 72 and noise_terrain_1 > 15 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if surface.can_place_entity {name="iron-ore", position={pos_x,pos_y}} then
surface.create_entity {name="iron-ore", position={pos_x,pos_y}, amount=resource_amount}
resource_entity_placed = true
end
end
if resource_entity_placed == false and noise_resources_coal_and_uranium + noise_resources > 70 and noise_terrain_1 > 15 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if surface.can_place_entity {name="coal", position={pos_x,pos_y}} then
surface.create_entity {name="coal", position={pos_x,pos_y}, amount=resource_amount}
resource_entity_placed = true
end
end
if resource_entity_placed == false and noise_resources_iron_and_copper + noise_resources < -72 and noise_terrain_1 > 15 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if surface.can_place_entity {name="copper-ore", position={pos_x,pos_y}} then
surface.create_entity {name="copper-ore", position={pos_x,pos_y}, amount=resource_amount}
resource_entity_placed = true
end
end
if resource_entity_placed == false and noise_resources_stone_and_oil + noise_resources > 72 and noise_terrain_1 > 15 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if surface.can_place_entity {name="stone", position={pos_x,pos_y}} then
surface.create_entity {name="stone", position={pos_x,pos_y}, amount=resource_amount}
resource_entity_placed = true
end
end
if resource_entity_placed == false and noise_resources_stone_and_oil + noise_resources < -70 and noise_terrain_1 < -50 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if math.random(1,42) == 1 then
if 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=(resource_amount*500)}
resource_entity_placed = true
end
end
end
if
resource_entity_placed == false and
noise_red_desert_rocks_1 + noise_red_desert_rocks_2 + noise_red_desert_rocks_3 > 20 and
noise_red_desert_rocks_1 + noise_red_desert_rocks_2 < 60 and
noise_terrain_1 > 7 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if math.random(1, 3) == 1 then
if math.random(1, 3) == 1 then
if surface.can_place_entity {name = 'sand-rock-big', position = {pos_x, pos_y}} then
surface.create_entity {name = 'sand-rock-big', position = {pos_x, pos_y}}
end
else
if surface.can_place_entity {name = 'sand-rock-big', position = {pos_x, pos_y}} then
surface.create_entity {name = 'sand-rock-big', position = {pos_x, pos_y}}
end
end
end
end
if resource_entity_placed == false and noise_red_desert_rocks_1 + noise_red_desert_rocks_2 + noise_red_desert_rocks_3 > 20 and noise_red_desert_rocks_1 + noise_red_desert_rocks_2 < 60 and noise_terrain_1 > 7 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if math.random(1,3) == 1 then
if math.random(1,3) == 1 then
if surface.can_place_entity {name="sand-rock-big", position={pos_x,pos_y}} then
surface.create_entity {name="sand-rock-big", position={pos_x,pos_y}}
end
else
if surface.can_place_entity {name="sand-rock-big", position={pos_x,pos_y}} then
surface.create_entity {name="sand-rock-big", position={pos_x,pos_y}}
end
end
end
end
if noise_red_desert_rocks_1 + noise_red_desert_rocks_2 + noise_red_desert_rocks_3 + noise_terrain_4 >= 10 and noise_red_desert_rocks_1 + noise_red_desert_rocks_2 + noise_red_desert_rocks_3 < 20 and noise_terrain_1 > 7 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4 then
if math.random(1,5) == 1 then
table.insert(global.planet_decoratives_hold, {name="rock-medium", position={pos_x,pos_y}, amount=1})
end
else
if tile_to_insert ~= "water" and tile_to_insert ~= "sand-1" then
if math.random(1,15) == 1 then
table.insert(global.planet_decoratives_hold, {name="sand-rock-small", position={pos_x,pos_y}, amount=1})
else
if math.random(1,8) == 1 then
table.insert(global.planet_decoratives_hold, {name="sand-rock-small", position={pos_x,pos_y}, amount=1})
end
end
end
end
if tile_to_insert ~= "water" then
if noise_decoratives_2 > 0.6 then
if math.random(1,9) == 1 then table.insert(global.planet_decoratives_hold, {name="red-asterisk", position={pos_x,pos_y}, amount=1}) end
else
if noise_decoratives_2 > 0.4 then
if math.random(1,17) == 1 then table.insert(global.planet_decoratives_hold, {name="red-asterisk", position={pos_x,pos_y}, amount=1}) end
end
end
if noise_decoratives_3 < -0.6 then
if math.random(1,2) == 1 then table.insert(global.planet_decoratives_hold, {name="brown-fluff-dry", position={pos_x,pos_y}, amount=1}) end
else
if noise_decoratives_3 < -0.4 then
if math.random(1,5) == 1 then table.insert(global.planet_decoratives_hold, {name="brown-fluff-dry", position={pos_x,pos_y}, amount=1}) end
end
end
end
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x,pos_y}})
end
if
noise_red_desert_rocks_1 + noise_red_desert_rocks_2 + noise_red_desert_rocks_3 + noise_terrain_4 >= 10 and
noise_red_desert_rocks_1 + noise_red_desert_rocks_2 + noise_red_desert_rocks_3 < 20 and
noise_terrain_1 > 7 + noise_terrain_2 + noise_terrain_3 + noise_terrain_4
then
if math.random(1, 5) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'rock-medium', position = {pos_x, pos_y}, amount = 1}
)
end
else
if tile_to_insert ~= 'water' and tile_to_insert ~= 'sand-1' then
if math.random(1, 15) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'sand-rock-small', position = {pos_x, pos_y}, amount = 1}
)
else
if math.random(1, 8) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'sand-rock-small', position = {pos_x, pos_y}, amount = 1}
)
end
end
end
end
if tile_to_insert ~= 'water' then
if noise_decoratives_2 > 0.6 then
if math.random(1, 9) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'red-asterisk', position = {pos_x, pos_y}, amount = 1}
)
end
else
if noise_decoratives_2 > 0.4 then
if math.random(1, 17) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'red-asterisk', position = {pos_x, pos_y}, amount = 1}
)
end
end
end
if noise_decoratives_3 < -0.6 then
if math.random(1, 2) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'brown-fluff-dry', position = {pos_x, pos_y}, amount = 1}
)
end
else
if noise_decoratives_3 < -0.4 then
if math.random(1, 5) == 1 then
table.insert(
global.planet_decoratives_hold,
{name = 'brown-fluff-dry', position = {pos_x, pos_y}, amount = 1}
)
end
end
end
end
table.insert(global.planet_tiles_hold, {name = tile_to_insert, position = {pos_x, pos_y}})
end
end

View File

@ -1,59 +1,59 @@
--Author: MewMew / (Threaded by Valansch)
require "map_gen.shared.perlin_noise"
local Event = require "utils.event"
local perlin = require 'map_gen.shared.perlin_noise'
local Event = require 'utils.event'
--SETTINGS:
local width_modifier = 0.8
local ore_base_amounts = {
["iron-ore"] = 700,
["coal"] = 400,
["copper-ore"] = 400,
["stone"] = 400,
["uranium-ore"] = 400
['iron-ore'] = 700,
['coal'] = 400,
['copper-ore'] = 400,
['stone'] = 400,
['uranium-ore'] = 400
}
local function init()
global.perlin_noise_seed = math.random(1000, 1000000)
global.perlin_noise_seed = math.random(1000, 1000000)
end
Event.on_init(init)
local function do_resource(name, x, y, world, noise_terrain, noise_band_high, noise_band_low, seed)
if noise_terrain > -noise_band_high * width_modifier and noise_terrain <= -noise_band_low * width_modifier then
local noise_resource_amount_modifier = perlin:noise(((x + seed) / 200), ((y + seed) / 200), 0)
local resource_amount =
1 +
((ore_base_amounts[name] + (ore_base_amounts[name] * noise_resource_amount_modifier * 0.2)) *
world.amount_distance_multiplicator)
if noise_terrain > -noise_band_high * width_modifier and noise_terrain <= -noise_band_low * width_modifier then
local noise_resource_amount_modifier = perlin:noise(((x + seed) / 200), ((y + seed) / 200), 0)
local resource_amount =
1 +
((ore_base_amounts[name] + (ore_base_amounts[name] * noise_resource_amount_modifier * 0.2)) *
world.amount_distance_multiplicator)
return {name = name, amount = resource_amount}
end
return {name = name, amount = resource_amount}
end
end
return function(x, y, world)
if not world.amount_distance_multiplicator then
local distance = math.sqrt(world.x * world.x + world.y * world.y)
local amount_distance_multiplicator = (((distance + 1) / 75) / 75) + 1
world.amount_distance_multiplicator = amount_distance_multiplicator
end
local entities = world.surface.find_entities_filtered {position = {world.x + 0.5, world.y + 0.5}, type = "resource"}
for _, e in ipairs(entities) do
if e.name ~= "crude-oil" then
e.destroy()
if not world.amount_distance_multiplicator then
local distance = math.sqrt(world.x * world.x + world.y * world.y)
local amount_distance_multiplicator = (((distance + 1) / 75) / 75) + 1
world.amount_distance_multiplicator = amount_distance_multiplicator
end
end
local seed = global.perlin_noise_seed
local entities = world.surface.find_entities_filtered {position = {world.x + 0.5, world.y + 0.5}, type = 'resource'}
for _, e in ipairs(entities) do
if e.name ~= 'crude-oil' then
e.destroy()
end
end
local noise_terrain_1 = perlin:noise(((x + seed) / 350), ((y + seed) / 350), 0)
local noise_terrain_2 = perlin:noise(((x + seed) / 50), ((y + seed) / 50), 0)
local noise_terrain = noise_terrain_1 + (noise_terrain_2 * 0.01)
local seed = global.perlin_noise_seed
return do_resource("iron-ore", x, y, world, noise_terrain, 0.1, 0.075, seed) or
do_resource("copper-ore", x, y, world, noise_terrain, 0.075, 0.05, seed) or
do_resource("stone", x, y, world, noise_terrain, 0.05, 0.04, seed) or
do_resource("coal", x, y, world, noise_terrain, 0.04, 0.03, seed) or
do_resource("uranium-ore", x, y, world, noise_terrain, 0.03, 0.02, seed)
local noise_terrain_1 = perlin:noise(((x + seed) / 350), ((y + seed) / 350), 0)
local noise_terrain_2 = perlin:noise(((x + seed) / 50), ((y + seed) / 50), 0)
local noise_terrain = noise_terrain_1 + (noise_terrain_2 * 0.01)
return do_resource('iron-ore', x, y, world, noise_terrain, 0.1, 0.075, seed) or
do_resource('copper-ore', x, y, world, noise_terrain, 0.075, 0.05, seed) or
do_resource('stone', x, y, world, noise_terrain, 0.05, 0.04, seed) or
do_resource('coal', x, y, world, noise_terrain, 0.04, 0.03, seed) or
do_resource('uranium-ore', x, y, world, noise_terrain, 0.03, 0.02, seed)
end

View File

@ -1,47 +1,51 @@
require "map_gen.shared.perlin_noise"
local perlin = require 'map_gen.shared.perlin_noise'
-- list of {x, y, ore_type, size, richness, rng_seed}
local ctrs = {
{1, -15, "iron-ore", 0.3, 400, 113},
{15, 15, "copper-ore", 0.3, 400, 80},
{4, 21, "coal", 0.25, 640, 31},
{10, 0, "stone", 0.5, 100, 17},
{-17, 7, "uranium-ore", 0.6, 100, 203}
{1, -15, 'iron-ore', 0.3, 400, 113},
{15, 15, 'copper-ore', 0.3, 400, 80},
{4, 21, 'coal', 0.25, 640, 31},
{10, 0, 'stone', 0.5, 100, 17},
{-17, 7, 'uranium-ore', 0.6, 100, 203}
}
local function harmonic(x, y)
local max_idx = 0
local max = -1
local richness = 0
for i, e in ipairs(ctrs) do
local noise = perlin:noise(x / 32, y / 32, ctrs[i][6])
local h_coeff =
1 /
(1 + .05 * math.sqrt((x / 32 - ctrs[i][1]) * (x / 32 - ctrs[i][1]) + (y / 32 - ctrs[i][2]) * (y / 32 - ctrs[i][2])))
if noise > max and noise > h_coeff * ctrs[i][4] + (1 - h_coeff) then
max = noise
max_idx = i
richness = (40 * (1 - h_coeff) + 0.5 * h_coeff) * ctrs[i][5]
end
end
return max, max_idx, richness
local max_idx = 0
local max = -1
local richness = 0
for i, e in ipairs(ctrs) do
local noise = perlin:noise(x / 32, y / 32, ctrs[i][6])
local h_coeff =
1 /
(1 +
.05 *
math.sqrt(
(x / 32 - ctrs[i][1]) * (x / 32 - ctrs[i][1]) + (y / 32 - ctrs[i][2]) * (y / 32 - ctrs[i][2])
))
if noise > max and noise > h_coeff * ctrs[i][4] + (1 - h_coeff) then
max = noise
max_idx = i
richness = (40 * (1 - h_coeff) + 0.5 * h_coeff) * ctrs[i][5]
end
end
return max, max_idx, richness
end
return function(x, y, world)
if math.abs(world.x / 32) < 3 and math.abs(world.y / 32) < 3 then
return
end
if math.abs(world.x / 32) < 3 and math.abs(world.y / 32) < 3 then
return
end
local entities = world.surface.find_entities_filtered {position = {world.x + 0.5, world.y + 0.5}, type = "resource"}
for _, e in ipairs(entities) do
if e.name ~= "crude-oil" then
e.destroy()
end
end
local entities = world.surface.find_entities_filtered {position = {world.x + 0.5, world.y + 0.5}, type = 'resource'}
for _, e in ipairs(entities) do
if e.name ~= 'crude-oil' then
e.destroy()
end
end
local max, max_idx, richness = harmonic(world.x, world.y)
local max, max_idx, richness = harmonic(world.x, world.y)
if -1 ~= max then
return {name = ctrs[max_idx][3], amount = richness}
end
if -1 ~= max then
return {name = ctrs[max_idx][3], amount = richness}
end
end

View File

@ -1,49 +1,49 @@
require "map_gen.shared.perlin_noise"
local Event = require "utils.event"
local perlin = require 'map_gen.shared.perlin_noise'
local Event = require 'utils.event'
local random_ores = {"iron-ore", "coal", "copper-ore", "stone", "uranium-ore"}
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
local function run_ores_module_setup()
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
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
end
Event.on_init(run_ores_module_setup)
return function(x, y, world)
local pos = {world.x + 0.5, world.y + 0.5}
return function(x, y, world)
local pos = {world.x + 0.5, world.y + 0.5}
local entities = world.surface.find_entities_filtered {position = pos, type = "resource"}
for _, e in ipairs(entities) do
e.destroy()
end
local entities = world.surface.find_entities_filtered {position = pos, type = 'resource'}
for _, e in ipairs(entities) do
e.destroy()
end
local distance_bonus = 200 + math.sqrt(world.x * world.x + world.y * world.y) * 0.2
local distance_bonus = 200 + math.sqrt(world.x * world.x + world.y * world.y) * 0.2
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
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 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])
--
return {name = random_ores[a], amount = res_amount}
elseif Ores_A < -60 then
if math.random(1, 200) == 1 then
return {name = "crude-oil", amount = math.random(5000, 20000) + math.floor(distance_bonus) * 1500}
end
end
return {name = random_ores[a], amount = res_amount}
elseif Ores_A < -60 then
if math.random(1, 200) == 1 then
return {name = 'crude-oil', amount = math.random(5000, 20000) + math.floor(distance_bonus) * 1500}
end
end
end

View File

@ -3,7 +3,7 @@
http://flafla2.github.io/2014/08/09/perlinnoise.html
]]--
perlin = {}
local perlin = {}
perlin.p = {}
-- Hash lookup table as defined by Ken Perlin
@ -125,3 +125,5 @@ end
function perlin.lerp(t, a, b)
return a + t * (b - a)
end
return perlin

View File

@ -1,181 +1,177 @@
local perlin = require 'map_gen.shared.perlin_noise'
require "map_gen.shared.perlin_noise"
local tree_to_place = {"dry-tree","dry-hairy-tree","tree-06","tree-06","tree-01","tree-02","tree-03"}
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
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 tileswater = {}
local area = event.area
local surface = event.surface
local tiles = {}
local tileswater = {}
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
elseif (run_ores_module ~= nil and entity.type == "resource") then
entity.destroy()
end
end
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
--end
entity.destroy()
elseif (run_ores_module ~= nil and entity.type == 'resource') then
entity.destroy()
end
end
local top_left = area.left_top --make a more direct reference
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
--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
--for x = 0, 31, 1 do
-- for y = 0, 31, 1 do
--game.print(top_left.x .."-" ..top_left.y .. " to " .. area.right_bottom.x .. "-" .. area.right_bottom.y)
--game.print(top_left.x .."-" ..top_left.y .. " to " .. area.right_bottom.x .. "-" .. area.right_bottom.y)
for x = top_left.x-1, top_left.x + 32 do
for y = top_left.y-1, top_left.y + 32 do
--local pos_x = top_left.x + x
--local pos_y = top_left.y + y
local tile = surface.get_tile(x,y)
for x = top_left.x - 1, top_left.x + 32 do
for y = top_left.y - 1, top_left.y + 32 do
--local pos_x = top_left.x + x
--local pos_y = top_left.y + y
local tile = surface.get_tile(x, y)
if tile.name ~= "out-of-map" then
if tile.name ~= 'out-of-map' then
local tile_to_insert = 'grass-3'
local tile_to_insert = "grass-3"
local wiggle = 50 + perlin:noise((x * 0.005), (y * 0.005), global.terrain_seed_A + 71) * 60
local terrain_A = perlin:noise((x * 0.005), (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((x * 0.001), (y * 0.001), global.terrain_seed_A + 5) * wiggle --terrain layer
local wiggle = 50 + perlin:noise((x*0.005),(y*0.005),global.terrain_seed_A + 71) * 60
local terrain_A = perlin:noise((x*0.005),(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((x*0.001),(y*0.001),global.terrain_seed_A + 5) * wiggle --terrain layer
--local wiggle = 50 + simplex_2d((x*0.005),(y*0.005),global.terrain_seed_A + 71) * 60
--local terrain_A = simplex_2d((x*0.005),(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 + simplex_2d((x*0.001),(y*0.001),global.terrain_seed_A + 5) * wiggle --terrain layer
--local wiggle = 50 + simplex_2d((x*0.005),(y*0.005),global.terrain_seed_A + 71) * 60
--local terrain_A = simplex_2d((x*0.005),(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 + simplex_2d((x*0.001),(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((x * 0.01), (y * 0.01), global.terrain_seed_A + 31) * 90 + (wiggle * -0.2) --we only gen this when we consider placing water
--terrain_A = simplex_2d((x*0.01),(y*0.01),global.terrain_seed_A + 31) * 90 + (wiggle * -0.2) --we only gen this when we consider placing water
if terrain_sqr < 50 then --Main water areas
--local deep = (terrain_sqr < 20) and true or false
terrain_A = perlin:noise((x*0.01),(y*0.01),global.terrain_seed_A + 31) * 90 + (wiggle * -0.2) --we only gen this when we consider placing water
--terrain_A = simplex_2d((x*0.01),(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
--table.insert(tileswater, {name = "water", position = {x,y}})
--table.insert(tileswater, {name = "water", position = {x+1,y}})
--table.insert(tileswater, {name = "water", position = {x,y+1}})
--table.insert(tileswater, {name = "water", position = {x+1,y+1}})
tile_to_insert = 'water'
else
if terrain_D >= 20 then
tile_to_insert = 'sand-1'
end
end
elseif terrain_sqr > 70 then
wiggle = 100 + perlin:noise((x * 0.01), (y * 0.01), global.terrain_seed_B + 41) * 60
local terrain_C = perlin:noise((x * 0.02), (y * 0.02), global.terrain_seed_A + 13) * wiggle --tree layer
if terrain_A * terrain_A > 40 then --creates random bridges over the water by overlapping with another noise layer
--wiggle = 100 + simplex_2d((x*0.01),(y*0.01),global.terrain_seed_B + 41) * 60
--local terrain_C = simplex_2d((x*0.02),(y*0.02),global.terrain_seed_A + 13) * wiggle --tree layer
tile_to_insert = "water"
--table.insert(tileswater, {name = "water", position = {x,y}})
--table.insert(tileswater, {name = "water", position = {x+1,y}})
--table.insert(tileswater, {name = "water", position = {x,y+1}})
--table.insert(tileswater, {name = "water", position = {x+1,y+1}})
--if surface.can_place_entity {name="stone", position={x,y}} then
-- surface.create_entity {name="stone", position={x,y}, amount=math.floor(terrain_sqr)}
--end
else
if terrain_D >= 20 then tile_to_insert = "sand-1" end
end
elseif terrain_sqr > 70 then
wiggle = 100 + perlin:noise((x*0.01),(y*0.01),global.terrain_seed_B + 41) * 60
local terrain_C = perlin:noise((x*0.02),(y*0.02),global.terrain_seed_A + 13) * wiggle --tree layer
if run_ores_module ~= nil then
run_ores_module_setup()
if x > top_left.x - 1 and x < top_left.x + 32 and y > top_left.y - 1 and y < top_left.y + 32 then
run_ores_module_tile(surface, x, y)
end
end
--wiggle = 100 + simplex_2d((x*0.01),(y*0.01),global.terrain_seed_B + 41) * 60
--local terrain_C = simplex_2d((x*0.02),(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
--if surface.can_place_entity {name="stone", position={x,y}} then
-- surface.create_entity {name="stone", position={x,y}, amount=math.floor(terrain_sqr)}
--end
--wiggle = 100 + perlin:noise((pos_x*0.02),(pos_y*0.02),global.terrain_seed_B + 71) * 60
if run_ores_module ~= nil then
run_ores_module_setup()
if x > top_left.x-1 and x < top_left.x+32 and y > top_left.y-1 and y < top_left.y+32 then
run_ores_module_tile(surface,x,y)
end
end
if terrain_D < 20 then
if terrain_C < 4 then --we set grass-1 around near forest areas
tile_to_insert = 'grass-1'
--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
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 = {x, y}} then
surface.create_entity {name = tree_to_place[treenum], position = {x, 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 = {x, y}} then
surface.create_entity {name = tree_to_place[treenum], position = {x, y}}
end
end
end
end
else
if terrain_D < 30 then
tile_to_insert = 'sand-1'
--wiggle = 100 + perlin:noise((pos_x*0.02),(pos_y*0.02),global.terrain_seed_B + 71) * 60
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 = {x, y}} then
surface.create_entity {name = tree_to_place[treenum], position = {x, 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 = {x, y}} then
surface.create_entity {name = tree_to_place[treenum], position = {x, y}}
end
end
else
--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
tile_to_insert = 'sand-3'
end
end
if
math.floor(terrain_D) % 5 == 1 and math.random(1, 70) == 1 and
surface.can_place_entity {name = 'rock-big', position = {x, y}}
then
surface.create_entity {name = 'rock-big', position = {x, y}}
end
else
if terrain_D >= 20 then
if terrain_D < 30 then
tile_to_insert = 'sand-1'
else
tile_to_insert = 'sand-3'
end
end
end
if terrain_D < 20 then
--if tile_to_insert == "water" then
--table.insert(tileswater, {name = tile_to_insert, position = {x,y}})
--else
table.insert(tiles, {name = tile_to_insert, position = {x, y}})
--end
end
end
end
--game.print("break end")
--game.print(lowest .. " to " .. highest)
if terrain_C < 4 then --we set grass-1 around near forest areas
tile_to_insert = "grass-1"
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={x,y}} then
surface.create_entity {name=tree_to_place[treenum], position={x,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={x,y}} then
surface.create_entity {name=tree_to_place[treenum], position={x,y}}
end
end
end
end
else
if terrain_D < 30 then
tile_to_insert = "sand-1"
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={x,y}} then
surface.create_entity {name=tree_to_place[treenum], position={x,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={x,y}} then
surface.create_entity {name=tree_to_place[treenum], position={x,y}}
end
end
else
tile_to_insert = "sand-3"
--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="rock-big", position={x,y}} then
surface.create_entity {name="rock-big", position={x,y}}
end
else
if terrain_D >= 20 then
if terrain_D < 30 then
tile_to_insert = "sand-1"
else
tile_to_insert = "sand-3"
end
end
end
--if tile_to_insert == "water" then
--table.insert(tileswater, {name = tile_to_insert, position = {x,y}})
--else
table.insert(tiles, {name = tile_to_insert, position = {x,y}})
--end
end
end
end
--game.print("break end")
--game.print(lowest .. " to " .. highest)
surface.set_tiles(tiles,true)
--surface.set_tiles(tileswater,true)
surface.set_tiles(tiles, true)
--surface.set_tiles(tileswater,true)
end

View File

@ -1,25 +1,25 @@
require "map_gen.shared.perlin_noise"
local Event = require "utils.event"
local perlin = require 'map_gen.shared.perlin_noise'
local Event = require 'utils.event'
local function init()
global.terrain_seed_A = math.random(10, 10000)
global.terrain_seed_B = math.random(10, 10000)
global.terrain_seed_A = math.random(10, 10000)
global.terrain_seed_B = math.random(10, 10000)
end
Event.on_init(init)
return function(x, y, world)
local wiggle = 50 + perlin:noise((x * 0.005), (y * 0.005), global.terrain_seed_A + 71) * 60
local terrain_A = perlin:noise((x * 0.005), (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 wiggle = 50 + perlin:noise((x * 0.005), (y * 0.005), global.terrain_seed_A + 71) * 60
local terrain_A = perlin:noise((x * 0.005), (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
if terrain_sqr < 50 then --Main water areas
terrain_A = perlin:noise((x * 0.01), (y * 0.01), global.terrain_seed_A + 31) * 90 + (wiggle * -0.2) --we only gen this when we consider placing water
if terrain_sqr < 50 then --Main water areas
terrain_A = perlin:noise((x * 0.01), (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
return "water"
end
end
if terrain_A * terrain_A > 40 then --creates random bridges over the water by overlapping with another noise layer
return 'water'
end
end
return true
return true
end