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

deleted junk and changed maze name

This commit is contained in:
Valansch 2017-07-16 14:10:10 +02:00
parent 907d222cb4
commit f582cb862c
6 changed files with 0 additions and 421 deletions

0
generate.lua → locale/gen_shape/maze.lua Executable file → Normal file
View File

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,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,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