forked from mtcontrib/minetest-mod-snow
Fix a couple of errors with first commit.
This commit is contained in:
parent
0a0a6e0fdb
commit
1aa4296680
25
mapgen.lua
25
mapgen.lua
@ -2,7 +2,7 @@
|
|||||||
minetest.register_on_generated(function(minp, maxp, seed)
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
if maxp.y >= -10 then
|
if maxp.y >= -10 then
|
||||||
local debug = snow.debug
|
local debug = snow.debug
|
||||||
|
|
||||||
--Choose a biome type.
|
--Choose a biome type.
|
||||||
local pr = PseudoRandom(seed+57)
|
local pr = PseudoRandom(seed+57)
|
||||||
local biome = pr:next(1, 10)
|
local biome = pr:next(1, 10)
|
||||||
@ -11,7 +11,7 @@ if maxp.y >= -10 then
|
|||||||
local cool = biome > 9 --only spawns ice on edge of water
|
local cool = biome > 9 --only spawns ice on edge of water
|
||||||
local icecave = biome == 5
|
local icecave = biome == 5
|
||||||
local icehole = biome == 6 --icesheet with holes
|
local icehole = biome == 6 --icesheet with holes
|
||||||
|
|
||||||
--Misc biome settings.
|
--Misc biome settings.
|
||||||
local icy = pr:next(1, 2) == 2 --If enabled spawns ice in sand instead of snow blocks.
|
local icy = pr:next(1, 2) == 2 --If enabled spawns ice in sand instead of snow blocks.
|
||||||
local mossy = pr:next(1,2) == 1 --Spawns moss in snow.
|
local mossy = pr:next(1,2) == 1 --Spawns moss in snow.
|
||||||
@ -27,22 +27,22 @@ if maxp.y >= -10 then
|
|||||||
|
|
||||||
--Should make things a bit faster.
|
--Should make things a bit faster.
|
||||||
local env = minetest.env
|
local env = minetest.env
|
||||||
|
|
||||||
--Debugging function
|
--Debugging function
|
||||||
local biomeToString = function(num)
|
local biomeToString = function(num)
|
||||||
if num == 1 or num == 7 or num == 8 then return "normal"
|
if num == 1 or num == 7 or num == 8 or num == 4 then return "normal"
|
||||||
elseif num == 2 then return "icebergs"
|
elseif num == 2 then return "icebergs"
|
||||||
elseif num == 3 then return "icesheet"
|
elseif num == 3 then return "icesheet"
|
||||||
elseif num == 5 then return "icecave"
|
elseif num == 5 then return "icecave"
|
||||||
elseif num == 9 or num == 10 then return "cool"
|
elseif num == 9 or num == 10 then return "cool"
|
||||||
elseif num == 6 then return "icehole"
|
elseif num == 6 then return "icehole"
|
||||||
else return "unknown" end
|
else return "unknown "..num end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Get map specific perlin
|
--Get map specific perlin
|
||||||
local perlin1 = env:get_perlin(112,3, 0.5, 150)
|
local perlin1 = env:get_perlin(112,3, 0.5, 150)
|
||||||
pr = PseudoRandom(seed+68)
|
pr = PseudoRandom(seed+68)
|
||||||
|
|
||||||
--Speed hack: checks the corners and middle of the chunk for "snow biome".
|
--Speed hack: checks the corners and middle of the chunk for "snow biome".
|
||||||
if not (perlin1:get2d({x=x0, y=z0}) > 0.53) and not (perlin1:get2d({x=x1, y=z1}) > 0.53)
|
if not (perlin1:get2d({x=x0, y=z0}) > 0.53) and not (perlin1:get2d({x=x1, y=z1}) > 0.53)
|
||||||
and not (perlin1:get2d({x=x0, y=z1}) > 0.53) and not (perlin1:get2d({x=x1, y=z0}) > 0.53)
|
and not (perlin1:get2d({x=x0, y=z1}) > 0.53) and not (perlin1:get2d({x=x1, y=z0}) > 0.53)
|
||||||
@ -50,19 +50,18 @@ if maxp.y >= -10 then
|
|||||||
if debug then print(biomeToString(biome)..": ABORTED!") end
|
if debug then print(biomeToString(biome)..": ABORTED!") end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--Loop through chunk.
|
--Loop through chunk.
|
||||||
for j=0,divs do
|
for j=0,divs do
|
||||||
for i=0,divs do
|
for i=0,divs do
|
||||||
|
|
||||||
local x = x0+i
|
local x = x0+i
|
||||||
local z = z0+j
|
local z = z0+j
|
||||||
|
|
||||||
--Check if we are in a "Snow biome"
|
--Check if we are in a "Snow biome"
|
||||||
local test = perlin1:get2d({x=x, y=z})
|
local test = perlin1:get2d({x=x, y=z})
|
||||||
if test > 0.53 then
|
if test > 0.53 then
|
||||||
|
|
||||||
|
|
||||||
-- Find ground level (0...15)
|
-- Find ground level (0...15)
|
||||||
local ground_y = nil
|
local ground_y = nil
|
||||||
for y=maxp.y,0,-1 do
|
for y=maxp.y,0,-1 do
|
||||||
@ -74,9 +73,9 @@ if maxp.y >= -10 then
|
|||||||
|
|
||||||
-- Snowy biome stuff
|
-- Snowy biome stuff
|
||||||
local node = env:get_node({x=x,y=ground_y,z=z})
|
local node = env:get_node({x=x,y=ground_y,z=z})
|
||||||
|
|
||||||
if ground_y and node.name == "default:dirt_with_grass" then
|
if ground_y and node.name == "default:dirt_with_grass" then
|
||||||
if shrubs and pr:next(1,28) == 1 then
|
if shrubs and pr:next(1,28) == 1 then
|
||||||
--Spawns dry shrubs.
|
--Spawns dry shrubs.
|
||||||
env:add_node({x=x,y=ground_y,z=z}, {name="snow:dirt_with_snow"})
|
env:add_node({x=x,y=ground_y,z=z}, {name="snow:dirt_with_snow"})
|
||||||
env:add_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
|
env:add_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
|
||||||
@ -97,6 +96,8 @@ if maxp.y >= -10 then
|
|||||||
else
|
else
|
||||||
env:add_node({x=x,y=ground_y,z=z}, {name="snow:ice"})
|
env:add_node({x=x,y=ground_y,z=z}, {name="snow:ice"})
|
||||||
end
|
end
|
||||||
|
elseif ground_y and env:get_node({x=x,y=ground_y,z=z}).name == "default:leaves" then
|
||||||
|
env:add_node({x=x,y=ground_y+1,z=z}, {name="snow:snow"})
|
||||||
elseif ground_y and node.name == "default:water_source" then
|
elseif ground_y and node.name == "default:water_source" then
|
||||||
if not icesheet and not icecave and not icehole then
|
if not icesheet and not icecave and not icehole then
|
||||||
--Coastal ice.
|
--Coastal ice.
|
||||||
|
Loading…
Reference in New Issue
Block a user