forked from mtcontrib/weather_pack
		
	MT 0.4.16 compatibility fixes and code clean-up.
This commit is contained in:
		
							
								
								
									
										6
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								init.lua
									
									
									
									
									
								
							@@ -11,6 +11,12 @@ if minetest.get_modpath("happy_weather_api") == nil then
 | 
				
			|||||||
	dofile(modpath.."/commands.lua")
 | 
						dofile(modpath.."/commands.lua")
 | 
				
			||||||
end
 | 
					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
 | 
					-- Happy Weather utilities
 | 
				
			||||||
dofile(modpath.."/utils.lua")
 | 
					dofile(modpath.."/utils.lua")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								utils.lua
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								utils.lua
									
									
									
									
									
								
							@@ -78,23 +78,27 @@ hw_utils.get_random_pos = function(player, offset)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local is_biome_frozen = function(position)
 | 
					local is_biome_frozen = function(position)
 | 
				
			||||||
 | 
						if legacy_MT_version then
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
	local heat = minetest.get_heat(position)
 | 
						local heat = minetest.get_heat(position)
 | 
				
			||||||
	print("karstis: " .. heat)
 | 
					 | 
				
			||||||
	-- below 35 heat biome considered to be frozen type
 | 
						-- below 35 heat biome considered to be frozen type
 | 
				
			||||||
	return heat < 35
 | 
						return heat < 35
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
hw_utils.is_biome_frozen = function(position)
 | 
					hw_utils.is_biome_frozen = function(position)
 | 
				
			||||||
	if mg_name == "v6" then
 | 
						if mg_name == "v6" then
 | 
				
			||||||
		return false -- v6 not supported yet.
 | 
							return false -- v6 not supported.
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	return is_biome_frozen(position)
 | 
						return is_biome_frozen(position)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local is_biome_dry = function(position)
 | 
					local is_biome_dry = function(position)
 | 
				
			||||||
 | 
						if legacy_MT_version then
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
	local humidity = minetest.get_humidity(position)
 | 
						local humidity = minetest.get_humidity(position)
 | 
				
			||||||
	local heat = minetest.get_heat(position)
 | 
						local heat = minetest.get_heat(position)
 | 
				
			||||||
	print("DREGME: " .. humidity)
 | 
					 | 
				
			||||||
	return humidity < 50 and heat > 65
 | 
						return humidity < 50 and heat > 65
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -106,6 +110,9 @@ hw_utils.is_biome_dry = function(position)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local is_biome_tropic = function(position)
 | 
					local is_biome_tropic = function(position)
 | 
				
			||||||
 | 
						if legacy_MT_version then
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
	local humidity = minetest.get_humidity(position)
 | 
						local humidity = minetest.get_humidity(position)
 | 
				
			||||||
	local heat = minetest.get_heat(position)
 | 
						local heat = minetest.get_heat(position)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,8 +11,8 @@ local snowstorm = {}
 | 
				
			|||||||
-- Weather identification code
 | 
					-- Weather identification code
 | 
				
			||||||
snowstorm.code = "snowstorm"
 | 
					snowstorm.code = "snowstorm"
 | 
				
			||||||
snowstorm.last_check = 0
 | 
					snowstorm.last_check = 0
 | 
				
			||||||
snowstorm.check_interval = 5
 | 
					snowstorm.check_interval = 300
 | 
				
			||||||
snowstorm.chance = 1
 | 
					snowstorm.chance = 0.05
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Keeps sound handler references
 | 
					-- Keeps sound handler references
 | 
				
			||||||
local sound_handlers = {}
 | 
					local sound_handlers = {}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user