2012-07-22 08:27:54 +02:00
|
|
|
--[[
|
2014-06-04 00:34:58 +02:00
|
|
|
--==============================
|
|
|
|
--==========================================================
|
|
|
|
LazyJ's Fork of Splizard's "Snow Biomes" Mod
|
|
|
|
by LazyJ
|
|
|
|
version: Umpteen-hundred and 7/5ths something or another.
|
|
|
|
2014_04_12
|
|
|
|
|
|
|
|
~~~
|
|
|
|
|
|
|
|
"Snow Biomes" Mod
|
|
|
|
By Splizard
|
|
|
|
|
|
|
|
Download:
|
|
|
|
http//forum.minetest.net/viewtopic.php?id=2290
|
|
|
|
http://github.com/Splizard/minetest-mod-snow/
|
|
|
|
|
|
|
|
--==========================================================
|
|
|
|
--==============================
|
|
|
|
|
2012-07-22 08:27:54 +02:00
|
|
|
Snow Biomes
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2015-05-29 12:11:17 +02:00
|
|
|
|
2012-07-22 08:27:54 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2015-05-29 12:11:17 +02:00
|
|
|
|
2012-07-22 08:27:54 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
|
|
|
]]--
|
|
|
|
|
2012-12-18 23:34:58 +01:00
|
|
|
|
2012-07-26 05:43:56 +02:00
|
|
|
|
2014-06-04 00:34:58 +02:00
|
|
|
-- Original Lua Files
|
2015-11-21 23:37:28 +01:00
|
|
|
--dofile(modpath.."/util.lua")
|
|
|
|
--dofile(modpath.."/mapgen.lua")
|
|
|
|
--dofile(modpath.."/sled.lua")
|
2014-06-04 00:34:58 +02:00
|
|
|
-- "falling_snow.lua" disabled since weather functions minetest.get_heat(pos) and minetest.get_humidity(pos)
|
|
|
|
-- have been removed from Minetest.
|
|
|
|
-- Until something else can be figured out, use paramat's "Snowdrift" mod instead.
|
2015-11-21 23:37:28 +01:00
|
|
|
-- dofile(modpath.."/falling_snow.lua")
|
2012-12-18 23:34:58 +01:00
|
|
|
|
2014-06-04 00:34:58 +02:00
|
|
|
-- Original init.lua File Broken into Smaller Files
|
2015-11-21 23:37:28 +01:00
|
|
|
local modpath = minetest.get_modpath("snow")
|
|
|
|
dofile(modpath.."/src/abms.lua")
|
|
|
|
dofile(modpath.."/src/aliases.lua")
|
|
|
|
dofile(modpath.."/src/crafting.lua")
|
2012-10-02 14:37:05 +02:00
|
|
|
|
2012-12-19 08:15:54 +01:00
|
|
|
|
2014-06-04 00:34:58 +02:00
|
|
|
-- The formspec menu didn't work when util.lua was the very first "dofile" so I moved
|
|
|
|
-- it and all the other original "dofiles", in order, to the bottom of the list. ~ LazyJ
|
2015-05-29 12:11:17 +02:00
|
|
|
-- Minetest would crash if the mapgen was called upon before the rest of other snow lua files so
|
2014-06-04 00:34:58 +02:00
|
|
|
-- I put it lower on the list and that seems to do the trick. ~ LazyJ
|
2015-11-21 23:37:28 +01:00
|
|
|
dofile(modpath.."/src/util.lua")
|
2015-11-22 01:21:21 +01:00
|
|
|
dofile(modpath.."/src/snowball.lua")
|
2014-06-04 00:34:58 +02:00
|
|
|
-- To get Xmas tree saplings, the "christmas_content", true or false, in "util.lua" has to be determined first.
|
|
|
|
-- That means "nodes.lua", where the saplings are controlled, has to come after "util.lua". ~ LazyJ
|
2015-11-21 23:37:28 +01:00
|
|
|
dofile(modpath.."/src/nodes.lua")
|
|
|
|
dofile(modpath.."/src/basic_stairs_slabs.lua")
|
|
|
|
dofile(modpath.."/src/mapgen.lua")
|
|
|
|
dofile(modpath.."/src/sled.lua")
|
|
|
|
dofile(modpath.."/src/falling_snow.lua")
|
2012-12-19 08:15:54 +01:00
|
|
|
|
2012-10-02 14:37:05 +02:00
|
|
|
|
2012-07-22 08:27:54 +02:00
|
|
|
|
2014-06-04 00:34:58 +02:00
|
|
|
-- Check for "MoreBlocks". If not found, skip this next "dofile".
|
2012-07-22 08:27:54 +02:00
|
|
|
|
2015-11-21 23:37:28 +01:00
|
|
|
if rawget(_G, "stairsplus")
|
|
|
|
and minetest.get_modpath("moreblocks") then
|
2012-07-22 08:27:54 +02:00
|
|
|
|
2015-11-21 23:37:28 +01:00
|
|
|
dofile(modpath.."/src/stairsplus.lua")
|
2012-07-22 08:27:54 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-11-22 01:21:21 +01:00
|
|
|
local is_uneven
|
2014-06-04 12:19:44 +02:00
|
|
|
--This function places snow checking at the same time for snow level and increasing as needed.
|
|
|
|
--This also takes into account sourrounding snow and makes snow even.
|
|
|
|
function snow.place(pos)
|
2014-06-09 03:30:08 +02:00
|
|
|
local node = minetest.get_node_or_nil(pos)
|
2015-05-29 12:11:17 +02:00
|
|
|
|
2014-10-26 22:36:35 +01:00
|
|
|
--Oops, maybe there is no node?
|
2015-05-23 19:53:30 +02:00
|
|
|
if not node
|
|
|
|
or not minetest.registered_nodes[node.name] then
|
2014-10-26 22:36:35 +01:00
|
|
|
return
|
|
|
|
end
|
2014-06-04 12:19:44 +02:00
|
|
|
|
2015-05-23 19:53:30 +02:00
|
|
|
if node.name == "default:snow" then
|
|
|
|
local level = minetest.get_node_level(pos)
|
|
|
|
if level < 63 then
|
2015-11-21 22:18:03 +01:00
|
|
|
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "leafdecay") == 0
|
2015-11-22 01:21:21 +01:00
|
|
|
and not is_uneven(pos) then
|
2015-06-03 22:09:32 +02:00
|
|
|
minetest.sound_play("default_snow_footstep", {pos=pos})
|
2015-05-23 19:53:30 +02:00
|
|
|
minetest.add_node_level(pos, 7)
|
|
|
|
end
|
|
|
|
elseif level == 63 then
|
|
|
|
local p = minetest.find_node_near(pos, 10, "default:dirt_with_grass")
|
|
|
|
if p
|
|
|
|
and minetest.get_node_light(p, 0.5) == 15 then
|
2015-06-03 22:09:32 +02:00
|
|
|
minetest.sound_play("default_grass_footstep", {pos=pos})
|
2015-05-23 19:53:30 +02:00
|
|
|
minetest.place_node({x=pos.x, y=pos.y+1, z=pos.z}, {name="default:snow"})
|
|
|
|
else
|
2015-06-03 22:09:32 +02:00
|
|
|
minetest.sound_play("default_snow_footstep", {pos=pos})
|
|
|
|
minetest.add_node(pos, {name="default:snowblock"})
|
2015-05-23 19:53:30 +02:00
|
|
|
end
|
2014-06-04 12:19:44 +02:00
|
|
|
end
|
2015-05-23 19:53:30 +02:00
|
|
|
elseif node.name ~= "default:ice"
|
2015-11-21 22:18:03 +01:00
|
|
|
and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name ~= "air" then
|
2015-06-03 22:09:32 +02:00
|
|
|
local data = minetest.registered_nodes[node.name]
|
|
|
|
local drawtype = data.drawtype
|
2015-05-23 19:53:30 +02:00
|
|
|
if drawtype == "normal"
|
|
|
|
or drawtype == "allfaces_optional" then
|
|
|
|
pos.y = pos.y+1
|
2015-06-03 22:09:32 +02:00
|
|
|
local sound = data.sounds
|
|
|
|
if sound then
|
|
|
|
sound = sound.footstep
|
|
|
|
if sound then
|
|
|
|
minetest.sound_play(sound.name, {pos=pos, gain=sound.gain})
|
|
|
|
end
|
|
|
|
end
|
2015-05-23 19:53:30 +02:00
|
|
|
minetest.place_node(pos, {name="default:snow"})
|
2014-06-04 12:19:44 +02:00
|
|
|
elseif drawtype == "plantlike" then
|
|
|
|
pos.y = pos.y - 1
|
|
|
|
if minetest.get_node(pos).name == "default:dirt_with_grass" then
|
2015-06-03 22:09:32 +02:00
|
|
|
minetest.sound_play("default_grass_footstep", {pos=pos})
|
2014-06-04 12:19:44 +02:00
|
|
|
minetest.add_node(pos, {name="default:dirt_with_snow"})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-08-06 08:25:01 +02:00
|
|
|
|
2014-06-04 00:34:58 +02:00
|
|
|
-- Checks if the snow level is even at any given pos.
|
|
|
|
-- Smooth Snow
|
2015-11-22 01:21:21 +01:00
|
|
|
local function uneven(pos)
|
2015-05-26 20:37:57 +02:00
|
|
|
local num = minetest.get_node_level(pos)
|
|
|
|
local get_node = minetest.get_node
|
|
|
|
local add_node = minetest.add_node
|
|
|
|
local foundx
|
|
|
|
local foundz
|
|
|
|
for z = -1,1 do
|
|
|
|
for x = -1,1 do
|
|
|
|
local p = {x=pos.x+x, y=pos.y, z=pos.z+z}
|
|
|
|
local node = get_node(p)
|
|
|
|
p.y = p.y-1
|
|
|
|
local bnode = get_node(p)
|
|
|
|
|
|
|
|
if node
|
|
|
|
and minetest.registered_nodes[node.name]
|
|
|
|
and minetest.registered_nodes[node.name].drawtype == "plantlike"
|
|
|
|
and bnode.name == "default:dirt_with_grass" then
|
|
|
|
add_node(p, {name="default:dirt_with_snow"})
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
p.y = p.y+1
|
|
|
|
if not (x == 0 and z == 0)
|
|
|
|
and node.name == "default:snow"
|
|
|
|
and minetest.get_node_level(p) < num then
|
|
|
|
foundx = x
|
|
|
|
foundz = z
|
|
|
|
elseif node.name == "air"
|
|
|
|
and bnode.name ~= "air"
|
|
|
|
and bnode.name ~= "default:snow" then
|
2015-05-23 19:53:30 +02:00
|
|
|
p.y = p.y-1
|
2015-05-26 20:37:57 +02:00
|
|
|
snow.place(p)
|
|
|
|
return true
|
2013-08-06 08:25:01 +02:00
|
|
|
end
|
|
|
|
end
|
2015-05-26 20:37:57 +02:00
|
|
|
end
|
2015-11-21 23:37:28 +01:00
|
|
|
if foundx then
|
2015-05-26 20:37:57 +02:00
|
|
|
local p = {x=pos.x+foundx, y=pos.y, z=pos.z+foundz}
|
2015-11-21 23:37:28 +01:00
|
|
|
if not is_uneven(p) then
|
2015-05-26 20:37:57 +02:00
|
|
|
minetest.add_node_level(p, 7)
|
2013-08-06 08:25:01 +02:00
|
|
|
end
|
2015-05-26 20:37:57 +02:00
|
|
|
return true
|
2013-08-06 08:25:01 +02:00
|
|
|
end
|
2015-05-26 20:37:57 +02:00
|
|
|
end
|
|
|
|
|
2015-11-22 01:21:21 +01:00
|
|
|
if snow.smooth_snow then
|
|
|
|
is_uneven = uneven
|
|
|
|
else
|
|
|
|
is_uneven = function() end
|
2013-08-06 08:25:01 +02:00
|
|
|
end
|
2015-11-22 01:21:21 +01:00
|
|
|
|
|
|
|
snow.register_on_configuring(function(name, v)
|
|
|
|
if name == "smooth_snow" then
|
|
|
|
if v then
|
|
|
|
is_uneven = uneven
|
|
|
|
else
|
|
|
|
is_uneven = function() end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|