mirror of
				https://github.com/t-affeldt/regional_weather.git
				synced 2025-11-04 09:55:35 +01:00 
			
		
		
		
	Improve heavy snow performance, add pedology support, add documentation
This commit is contained in:
		@@ -8,7 +8,14 @@ local BLOCK_NAME = "regional_weather:ice"
 | 
			
		||||
minetest.register_node(BLOCK_NAME, {
 | 
			
		||||
	tiles = {"(default_ice.png^[colorize:#ffffff:50)^[opacity:200"},
 | 
			
		||||
	paramtype = "light",
 | 
			
		||||
	groups = {cracky = 3, cools_lava = 1, slippery = 3, dig_immediate = 2},
 | 
			
		||||
	groups = {
 | 
			
		||||
		cracky = 3,
 | 
			
		||||
		cools_lava = 1,
 | 
			
		||||
		slippery = 3,
 | 
			
		||||
		dig_immediate = 2,
 | 
			
		||||
		melts = 1
 | 
			
		||||
	},
 | 
			
		||||
	freezemelt = "default:river_water_source",
 | 
			
		||||
	sounds = default.node_sound_glass_defaults(),
 | 
			
		||||
	use_texture_alpha = true,
 | 
			
		||||
	drop = "",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										28
									
								
								abms/pedology.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								abms/pedology.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
if not regional_weather.settings.pedology
 | 
			
		||||
or not minetest.get_modpath("pedology")
 | 
			
		||||
then return end
 | 
			
		||||
 | 
			
		||||
climate_api.register_abm({
 | 
			
		||||
	label			= "wetten or dry pedology nodes",
 | 
			
		||||
	nodenames = { "group:sucky" },
 | 
			
		||||
	neighbors = { "air" },
 | 
			
		||||
	interval	= 25,
 | 
			
		||||
	chance		= 30,
 | 
			
		||||
	catch_up	= false,
 | 
			
		||||
 | 
			
		||||
	conditions	= {
 | 
			
		||||
		min_height		= regional_weather.settings.min_height,
 | 
			
		||||
		max_height		= regional_weather.settings.max_height,
 | 
			
		||||
		min_heat			= 25,
 | 
			
		||||
		min_light			= 15
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	action = function (pos, node, env)
 | 
			
		||||
		local wetness = minetest.get_item_group(node.name, "wet") or 0
 | 
			
		||||
		if wetness < 2 and env.humidity > 55 then
 | 
			
		||||
			pedology.wetten(pos)
 | 
			
		||||
		elseif wetness > 0 and wetness < 3 and env.humidity < 40 then
 | 
			
		||||
			pedology.dry(pos)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
})
 | 
			
		||||
@@ -77,7 +77,7 @@ climate_api.register_abm({
 | 
			
		||||
	 end,
 | 
			
		||||
 | 
			
		||||
   action = function (pos, node, env)
 | 
			
		||||
		 if minetest.get_node(pos).name ~= "air" then return end
 | 
			
		||||
		 if node.name ~= "air" then return end
 | 
			
		||||
		 local base = minetest.get_node(vector.add(pos, {x=0, y=-1, z=0})).name
 | 
			
		||||
		 local is_soil = minetest.get_item_group(base, "soil") or 0
 | 
			
		||||
		 local is_stone = minetest.get_item_group(base, "stone") or 0
 | 
			
		||||
@@ -109,8 +109,7 @@ climate_api.register_abm({
 | 
			
		||||
	 },
 | 
			
		||||
 | 
			
		||||
   action = function (pos, node, env)
 | 
			
		||||
		 local node_name = minetest.get_node(pos).name
 | 
			
		||||
		 local value = minetest.get_item_group(node_name, "regional_weather_snow_cover")
 | 
			
		||||
		 local value = minetest.get_item_group(node.name, "regional_weather_snow_cover")
 | 
			
		||||
		 if value == nil then value = 0 end
 | 
			
		||||
		 if value < 5 then
 | 
			
		||||
			 minetest.set_node(pos, { name = BLOCK_PREFIX .. (value + 1) })
 | 
			
		||||
@@ -130,8 +129,7 @@ climate_api.register_abm({
 | 
			
		||||
	 },
 | 
			
		||||
 | 
			
		||||
   action = function (pos, node, env)
 | 
			
		||||
			local node_name = minetest.get_node(pos).name
 | 
			
		||||
			local value = minetest.get_item_group(node_name, "regional_weather_snow_cover")
 | 
			
		||||
			local value = minetest.get_item_group(node.name, "regional_weather_snow_cover")
 | 
			
		||||
			if value == nil then value = 0 end
 | 
			
		||||
			if value > 1 then
 | 
			
		||||
				minetest.set_node(pos, { name = BLOCK_PREFIX .. (value - 1) })
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,11 @@
 | 
			
		||||
--[[
 | 
			
		||||
# Player Damage Effect
 | 
			
		||||
Use this effect to damage a player during dangerous weather events.
 | 
			
		||||
Expects a table as the parameter containing the following values:
 | 
			
		||||
- ``value <number>``: The amount of damage to be applied per successful roll per cycle
 | 
			
		||||
- ``chance <number>``: Defines a 1/x chance for the player to get damaged. Higher values result in less frequent damage.
 | 
			
		||||
]]
 | 
			
		||||
 | 
			
		||||
if not minetest.is_yes(minetest.settings:get_bool("enable_damage"))
 | 
			
		||||
or not regional_weather.settings.damage then return end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,10 @@
 | 
			
		||||
--[[
 | 
			
		||||
# Lightning Effect
 | 
			
		||||
Use this effect to cause lightning strikes.
 | 
			
		||||
Requires lightning mod in order to function.
 | 
			
		||||
Uses default lightning configuration. Expects any non-nil parameter.
 | 
			
		||||
]]
 | 
			
		||||
 | 
			
		||||
if not minetest.get_modpath("lightning") then return end
 | 
			
		||||
 | 
			
		||||
local EFFECT_NAME = "regional_weather:lightning"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,9 @@
 | 
			
		||||
--[[
 | 
			
		||||
# Player Speed Effect
 | 
			
		||||
Use this effect to modify a player's movement speed.
 | 
			
		||||
Expects a numeric value that will be multiplied with the current speed physics.
 | 
			
		||||
]]
 | 
			
		||||
 | 
			
		||||
local EFFECT_NAME = "regional_weather:speed_buff"
 | 
			
		||||
 | 
			
		||||
local function handle_effect(player_data)
 | 
			
		||||
 
 | 
			
		||||
@@ -17,24 +17,13 @@ effects["climate_api:hud_overlay"] = {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
effects["climate_api:particles"] = {
 | 
			
		||||
	min_pos = {x=-8, y=3, z=-8},
 | 
			
		||||
	max_pos = {x= 8, y=6, z= 8},
 | 
			
		||||
	exptime=6,
 | 
			
		||||
	size=10,
 | 
			
		||||
	min_pos = {x=-7, y=3, z=-7},
 | 
			
		||||
	max_pos = {x= 7, y=6, z= 7},
 | 
			
		||||
	exptime=7.5,
 | 
			
		||||
	size=15,
 | 
			
		||||
	amount=6,
 | 
			
		||||
	falling_speed = 0.75,
 | 
			
		||||
	texture="weather_snow.png"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local function generate_effects(params)
 | 
			
		||||
	local avg_humidity = 55
 | 
			
		||||
	local intensity = params.humidity / avg_humidity
 | 
			
		||||
	local override = {}
 | 
			
		||||
 | 
			
		||||
	override["climate_api:particles"] = {
 | 
			
		||||
		amount = 16 * math.min(intensity, 1.5),
 | 
			
		||||
		falling_speed = 1 / math.min(intensity, 1.3)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return climate_api.utility.merge_tables(effects, override)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
climate_api.register_weather(name, conditions, generate_effects)
 | 
			
		||||
climate_api.register_weather(name, conditions, effects)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								init.lua
									
									
									
									
									
								
							@@ -21,6 +21,7 @@ regional_weather.settings.puddles			= get_setting_bool("puddles", true)
 | 
			
		||||
regional_weather.settings.soil				= get_setting_bool("soil", true)
 | 
			
		||||
regional_weather.settings.fire				= get_setting_bool("fire", true)
 | 
			
		||||
regional_weather.settings.ice					= get_setting_bool("ice", true)
 | 
			
		||||
regional_weather.settings.pedology		= get_setting_bool("pedology", true)
 | 
			
		||||
regional_weather.settings.max_height	= get_setting_number("max_height", 120)
 | 
			
		||||
regional_weather.settings.min_height	= get_setting_number("min_height", -50)
 | 
			
		||||
 | 
			
		||||
@@ -55,4 +56,5 @@ dofile(modpath .. "/abms/puddle.lua")
 | 
			
		||||
dofile(modpath .. "/abms/snow_cover.lua")
 | 
			
		||||
dofile(modpath .. "/abms/fire.lua")
 | 
			
		||||
dofile(modpath .. "/abms/ice.lua")
 | 
			
		||||
dofile(modpath .. "/abms/pedology.lua")
 | 
			
		||||
dofile(modpath .. "/abms/soil.lua")
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								mod.conf
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								mod.conf
									
									
									
									
									
								
							@@ -3,7 +3,7 @@ title = Regional Weather
 | 
			
		||||
author = TestificateMods
 | 
			
		||||
release = 1
 | 
			
		||||
depends = climate_api
 | 
			
		||||
optional_depends = default, lightning, farming, fire
 | 
			
		||||
optional_depends = default, lightning, farming, fire, pedology
 | 
			
		||||
description = """
 | 
			
		||||
Not every biome is the same and neither should their weather be.
 | 
			
		||||
Regional Weather controls it's effects with the local climate in mind.
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,8 @@ regional_weather_soil (Hydrate farmland) bool true
 | 
			
		||||
# If set to true, fires will be extinguished during rain showers.
 | 
			
		||||
regional_weather_fire (Extinguish fire) bool true
 | 
			
		||||
 | 
			
		||||
# If set to true, rain will wetten or dry nodes from pedology mod.
 | 
			
		||||
regional_weather_pedology (Wetten pedology nodes) bool true
 | 
			
		||||
 | 
			
		||||
[World Configuration]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user