1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

remove junk files

This commit is contained in:
Valansch 2017-07-18 21:30:14 +02:00
parent b2c79936e9
commit 428ecabbe7
11 changed files with 0 additions and 1542 deletions

View File

@ -1,57 +0,0 @@
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

View File

@ -1,20 +0,0 @@
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

View File

@ -1,26 +0,0 @@
--[[
This is a sample file for a map style. You may register new events, but not on_chunk_generated.
Author: Valansch
]]--
--This is contains the module (Do not remove)
local module = {}
local example_variable = "foo"
local function helper_function()
--helper function code here
end
--This function is called by the framework if the style is enabled.
function module.on_chunk_generated(event)
game.print("Chunk was generated")
end
--(Do not remove)
return module
--any code past this point will obviously not be executed

View File

@ -1,19 +0,0 @@
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

View File

@ -1,535 +0,0 @@
--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

View File

@ -1,146 +0,0 @@
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

View File

@ -1,145 +0,0 @@
--Author Neko Baron
--Passive data needed
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 tree_to_place = {"dry-tree","dry-hairy-tree","tree-06","tree-06","tree-01","tree-02","tree-03"}
--stuff we need to keep handled
function worldgen_init(event)
global.seed_A = math.random(10,100000)
global.seed_B = math.random(10,100000)
global.worldgen = true
end
function worldgen_onchunk(event)
if not global.worldgen then worldgen_init(event) end --Just a cheap lazy idea if I want to setup multiple seeds or suck at start.
local surface = game.surfaces[1]
local tiles = {}
local decoratives = {}
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
local top_left = event.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.seed_A + 71) * 60
local terrain_A = perlin:noise((pos_x*0.005),(pos_y*0.005),global.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.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.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.seed_B + 41) * 60
local terrain_B = perlin:noise((pos_x*0.01),(pos_y*0.01),global.seed_B + 57) * wiggle --ores layer
local terrain_C = perlin:noise((pos_x*0.02),(pos_y*0.02),global.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 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
surface.set_tiles(tiles,true)
for _,deco in pairs(decoratives) do
surface.create_decoratives{check_collision=false, decoratives={deco}}
end
end

View File

@ -1,71 +0,0 @@
-- original code by Ken Perlin: http://mrl.nyu.edu/~perlin/noise/
perlin = {}
perlin.p = {}
perlin.permutation = { 151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180
}
perlin.size = 256
perlin.gx = {}
perlin.gy = {}
perlin.randMax = 256
function perlin:load( )
for i=1,self.size do
self.p[i] = self.permutation[i]
self.p[256+i] = self.p[i]
end
end
function perlin:noise( x, y, z )
local X = math.floor(x) % 256
local Y = math.floor(y) % 256
local Z = math.floor(z) % 256
x = x - math.floor(x)
y = y - math.floor(y)
z = z - math.floor(z)
local u = fade(x)
local v = fade(y)
local w = fade(z)
local A = self.p[X+1]+Y
local AA = self.p[A+1]+Z
local AB = self.p[A+2]+Z
local B = self.p[X+2]+Y
local BA = self.p[B+1]+Z
local BB = self.p[B+2]+Z
return lerp(w, lerp(v, lerp(u, grad(self.p[AA+1], x , y , z ),
grad(self.p[BA+1], x-1, y , z )),
lerp(u, grad(self.p[AB+1], x , y-1, z ),
grad(self.p[BB+1], x-1, y-1, z ))),
lerp(v, lerp(u, grad(self.p[AB+2], x , y , z-1),
grad(self.p[BA+2], x-1, y , z-1)),
lerp(u, grad(self.p[AB+2], x , y-1, z-1),
grad(self.p[BB+2], x-1, y-1, z-1))))
end
function fade( t )
return t * t * t * (t * (t * 6 - 15) + 10)
end
function lerp( t, a, b )
return a + t * (b - a)
end
function grad( hash, x, y, z )
local h = hash % 16
local u = h < 8 and x or y
local v = h < 4 and y or ((h == 12 or h == 14) and x or z)
return ((h % 2) == 0 and u or -u) + ((h % 3) == 0 and v or -v)
end

File diff suppressed because one or more lines are too long

View File

@ -1,344 +0,0 @@
--Author MewMew
local module = {}
require "locale.map_layout.perlin_noise"
perlin:load( )
local wreck_item_pool = {}
local 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
end
function module.on_chunk_generated(event)
if not global.perlin_noise_seed then global.perlin_noise_seed = math.random(1000,1000000) end
local surface = game.surfaces[1]
local tiles = {}
local decoratives = {}
local tree_to_place = {"dry-tree","dry-hairy-tree","tree-06","tree-06","tree-01","tree-02","tree-03"}
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
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local pos_x = event.area.left_top.x + x
local pos_y = event.area.left_top.y + y
local tile = surface.get_tile(pos_x,pos_y)
local tile_to_insert = "concrete"
local a = pos_x
local b = pos_y
local c = 1
if event.area.right_bottom.x < 0 then a = event.area.right_bottom.x * -1 end
if event.area.right_bottom.y < 0 then b = event.area.right_bottom.y * -1 end
if a > b then c = a else c = b end
local resource_amount_distance_multiplicator = (((c + 1) / 75) / 75) + 1
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 seed_increment_number = 10000
local seed = global.perlin_noise_seed
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
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
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
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"
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"
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(tiles, {name = tile_to_insert, position = {a,pos_y}})
local a = pos_y + 1
table.insert(tiles, {name = tile_to_insert, position = {pos_x,a}})
local a = pos_x - 1
table.insert(tiles, {name = tile_to_insert, position = {a,pos_y}})
local a = pos_y - 1
table.insert(tiles, {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(decoratives, {name="green-carpet-grass", position={pos_x,pos_y}, amount=1})
end
if math.random(1,15) == 1 then
table.insert(decoratives, {name="brown-cane-cluster", 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(decoratives, {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(decoratives, {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(decoratives, {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(decoratives, {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
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,45) == 1 then
table.insert(decoratives, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
end
if math.random(1,20) == 1 then
table.insert(decoratives, {name="red-desert-rock-tiny", position={pos_x,pos_y}, amount=1})
end
else
if math.random(1,375) == 1 then
table.insert(decoratives, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
end
if math.random(1,45) == 1 then
table.insert(decoratives, {name="red-desert-rock-tiny", position={pos_x,pos_y}, amount=1})
end
end
end
else
tile_to_insert = "red-desert-dark"
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="red-desert-rock-huge-01", position={pos_x,pos_y}} then
surface.create_entity {name="red-desert-rock-huge-01", position={pos_x,pos_y}}
end
else
if surface.can_place_entity {name="red-desert-rock-big-01", position={pos_x,pos_y}} then
surface.create_entity {name="red-desert-rock-big-01", 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(decoratives, {name="red-desert-rock-medium", position={pos_x,pos_y}, amount=1})
end
else
if tile_to_insert ~= "water" and tile_to_insert ~= "sand" then
if math.random(1,15) == 1 then
table.insert(decoratives, {name="red-desert-rock-small", position={pos_x,pos_y}, amount=1})
else
if math.random(1,8) == 1 then
table.insert(decoratives, {name="red-desert-rock-tiny", 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(decoratives, {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(decoratives, {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(decoratives, {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(decoratives, {name="brown-fluff-dry", position={pos_x,pos_y}, amount=1}) end
end
end
end
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})
end
end
end
return module

View File

@ -1,44 +0,0 @@
--Author Valansch
Compass = {
east={x=1,y=0,next="north"},
north={x=0,y=-1,next="west"},
west={x=-1,y=0,next="south"},
south={x=0,y=1,next="east"},
direction="west"}
function Compass.turn()
Compass.direction=Compass[Compass.direction].next
end
function Compass.getdirection()
return Compass[Compass.direction]
end
--spiral
Spiral = {Pixels={}, width = 4, size = 10}
function Spiral.onshape(p)
x = math.floor(p[1]/32/Spiral.width)
y = math.floor(p[2]/32/Spiral.width)
return Spiral.Pixels[x .. "," .. y] ~= nil
end
function Spiral.add(p)
Spiral.Pixels[p[1].. "," .. p[2]] = true
end
function Spiral.takesteps(p, n)
direction = Compass.getdirection()
for i = 1, n do
p[1] = p[1] + direction["x"]
p[2] = p[2] + direction["y"]
Spiral.add(p)
end
return p
end
function Spiral.build()
p = {-1,-1}
Spiral.add(p)
for i = 1, 100 do
p = Spiral.takesteps(p, i)
Compass.turn()
end
end