MT 0.4.16 compatibility fixes and code clean-up.

This commit is contained in:
Arturas Norkus 2019-07-19 20:06:28 +03:00
parent c6987629e5
commit 2a8c2d0566
3 changed files with 18 additions and 5 deletions

View File

@ -11,6 +11,12 @@ if minetest.get_modpath("happy_weather_api") == nil then
dofile(modpath.."/commands.lua")
end
legacy_MT_version = false
if minetest.get_humidity == nil then
minetest.log("warning", "MOD [weather_pack]: Old Minetest version detected, some mod features will not work.")
legacy_MT_version = true
end
-- Happy Weather utilities
dofile(modpath.."/utils.lua")

View File

@ -78,23 +78,27 @@ hw_utils.get_random_pos = function(player, offset)
end
local is_biome_frozen = function(position)
if legacy_MT_version then
return false;
end
local heat = minetest.get_heat(position)
print("karstis: " .. heat)
-- below 35 heat biome considered to be frozen type
return heat < 35
end
hw_utils.is_biome_frozen = function(position)
if mg_name == "v6" then
return false -- v6 not supported yet.
return false -- v6 not supported.
end
return is_biome_frozen(position)
end
local is_biome_dry = function(position)
if legacy_MT_version then
return false;
end
local humidity = minetest.get_humidity(position)
local heat = minetest.get_heat(position)
print("DREGME: " .. humidity)
return humidity < 50 and heat > 65
end
@ -106,6 +110,9 @@ hw_utils.is_biome_dry = function(position)
end
local is_biome_tropic = function(position)
if legacy_MT_version then
return false;
end
local humidity = minetest.get_humidity(position)
local heat = minetest.get_heat(position)

View File

@ -11,8 +11,8 @@ local snowstorm = {}
-- Weather identification code
snowstorm.code = "snowstorm"
snowstorm.last_check = 0
snowstorm.check_interval = 5
snowstorm.chance = 1
snowstorm.check_interval = 300
snowstorm.chance = 0.05
-- Keeps sound handler references
local sound_handlers = {}