2013-08-06 08:25:01 +02:00
|
|
|
local mgname = ""
|
|
|
|
|
|
|
|
--Identify the mapgen.
|
|
|
|
if minetest.register_on_mapgen_init then
|
|
|
|
minetest.register_on_mapgen_init(function(MapgenParams)
|
|
|
|
if MapgenParams.mgname then
|
|
|
|
mgname = MapgenParams.mgname
|
|
|
|
else
|
|
|
|
io.write("[MOD] Snow Biomes: WARNING! mapgen could not be identifyed!\n")
|
|
|
|
end
|
|
|
|
if mgname == "v7" then
|
|
|
|
--Load mapgen_v7 compatibility.
|
|
|
|
dofile(minetest.get_modpath("snow").."/mapgen_v7.lua")
|
|
|
|
else
|
|
|
|
--Load mapgen_v6 compatibility.
|
|
|
|
dofile(minetest.get_modpath("snow").."/mapgen_v6.lua")
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
else
|
|
|
|
--Fall back to mapgen_v6.
|
|
|
|
dofile(minetest.get_modpath("snow").."/mapgen_v6.lua")
|
|
|
|
end
|
|
|
|
|
2013-03-19 23:08:16 +01:00
|
|
|
local pine_tree = {
|
|
|
|
axiom="TABff",
|
|
|
|
rules_a="[&T+f+ff+ff+ff+f]GA",
|
|
|
|
rules_b="[&T+f+Gf+Gf+Gf]GB",
|
|
|
|
trunk="default:tree",
|
|
|
|
leaves="snow:needles",
|
|
|
|
angle=90,
|
|
|
|
iterations=1,
|
|
|
|
random_level=0,
|
|
|
|
trunk_type="single",
|
|
|
|
thin_branches=true,
|
|
|
|
}
|
|
|
|
local xmas_tree = {
|
|
|
|
axiom="TABff",
|
|
|
|
rules_a="[&T+f+ff+ff+ff+f]GA",
|
|
|
|
rules_b="[&T+f+Gf+Gf+Gf]GB",
|
|
|
|
trunk="default:tree",
|
|
|
|
leaves="snow:needles_decorated",
|
|
|
|
angle=90,
|
|
|
|
iterations=1,
|
|
|
|
random_level=0,
|
|
|
|
trunk_type="single",
|
|
|
|
thin_branches=true,
|
|
|
|
}
|
|
|
|
|
2012-07-26 05:43:56 +02:00
|
|
|
--Makes pine tree
|
2012-12-18 23:34:58 +01:00
|
|
|
function snow.make_pine(pos,snow,xmas)
|
2012-07-26 05:43:56 +02:00
|
|
|
local env = minetest.env
|
2012-12-19 08:27:49 +01:00
|
|
|
local perlin1 = env:get_perlin(112,3, 0.5, 150)
|
2012-12-18 09:05:13 +01:00
|
|
|
local try_node = function(pos, node)
|
|
|
|
local n = env:get_node(pos).name
|
2013-03-19 23:08:16 +01:00
|
|
|
if n == "air" or n == "ignore" then
|
2012-12-18 09:05:13 +01:00
|
|
|
env:add_node(pos,node)
|
|
|
|
end
|
|
|
|
end
|
2012-07-26 05:43:56 +02:00
|
|
|
--Clear ground.
|
|
|
|
for x=-1,1 do
|
|
|
|
for z=-1,1 do
|
|
|
|
if env:get_node({x=pos.x+x,y=pos.y,z=pos.z+z}).name == "snow:snow" then
|
|
|
|
env:remove_node({x=pos.x+x,y=pos.y,z=pos.z+z})
|
|
|
|
end
|
2012-12-18 00:51:27 +01:00
|
|
|
if env:get_node({x=pos.x+x,y=pos.y,z=pos.z+z}).name == "snow:snow_block" then
|
|
|
|
env:remove_node({x=pos.x+x,y=pos.y,z=pos.z+z})
|
|
|
|
end
|
2012-07-26 05:43:56 +02:00
|
|
|
end
|
|
|
|
end
|
2013-03-19 23:08:16 +01:00
|
|
|
if xmas then
|
|
|
|
env:remove_node(pos)
|
|
|
|
minetest.env:spawn_tree(pos, xmas_tree)
|
|
|
|
else
|
|
|
|
minetest.env:spawn_tree(pos, pine_tree)
|
|
|
|
end
|
|
|
|
if snow then
|
|
|
|
local x,z = pos.x,pos.z
|
|
|
|
try_node({x=x+1,y=pos.y+3,z=z+1},{name="snow:snow"})
|
|
|
|
try_node({x=x-1,y=pos.y+3,z=z-1},{name="snow:snow"})
|
|
|
|
try_node({x=x-1,y=pos.y+3,z=z+1},{name="snow:snow"})
|
|
|
|
try_node({x=x+1,y=pos.y+3,z=z-1},{name="snow:snow"})
|
|
|
|
|
|
|
|
try_node({x=x+1,y=pos.y+5,z=z},{name="snow:snow"})
|
|
|
|
try_node({x=x-1,y=pos.y+5,z=z},{name="snow:snow"})
|
|
|
|
try_node({x=x,y=pos.y+5,z=z+1},{name="snow:snow"})
|
|
|
|
try_node({x=x,y=pos.y+5,z=z-1},{name="snow:snow"})
|
2012-07-26 05:43:56 +02:00
|
|
|
end
|
2012-12-18 23:34:58 +01:00
|
|
|
if xmas then
|
|
|
|
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:star"})
|
|
|
|
elseif snow and perlin1:get2d({x=pos.x,y=pos.z}) > 0.53 then
|
2012-12-18 09:05:13 +01:00
|
|
|
try_node({x=pos.x,y=pos.y+7,z=pos.z},{name="snow:snow"})
|
2012-07-26 05:43:56 +02:00
|
|
|
end
|
|
|
|
end
|