mirror of
				https://github.com/t-affeldt/climate_api.git
				synced 2025-11-04 09:55:35 +01:00 
			
		
		
		
	Compare commits
	
		
			20 Commits
		
	
	
		
			a56116e8ab
			...
			85e4553f2a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					85e4553f2a | ||
| 
						 | 
					8b846b23dc | ||
| 
						 | 
					8e3ce58015 | ||
| 
						 | 
					04cfef309a | ||
| 
						 | 
					2093eea77f | ||
| 
						 | 
					c23277284a | ||
| 
						 | 
					5448e04d85 | ||
| 
						 | 
					79233a2cb1 | ||
| 
						 | 
					f3f0eaac2a | ||
| 
						 | 
					0dd5c74d42 | ||
| 
						 | 
					d1c70e904b | ||
| 
						 | 
					7d299edb5b | ||
| 
						 | 
					bf2d4e09ca | ||
| 
						 | 
					4d0b080dd5 | ||
| 
						 | 
					eff85fbd2b | ||
| 
						 | 
					5635ab4daa | ||
| 
						 | 
					e8f4048670 | ||
| 
						 | 
					dd769dfdd0 | ||
| 
						 | 
					710a1d717b | ||
| 
						 | 
					59bf43aa28 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					*.code-workspace
 | 
				
			||||||
@@ -43,7 +43,7 @@ local function check_hit(player, ray)
 | 
				
			|||||||
		)
 | 
							)
 | 
				
			||||||
		origin = vector.add(origin, windpos)
 | 
							origin = vector.add(origin, windpos)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	local ray = minetest.raycast(origin, ppos)
 | 
						ray = minetest.raycast(origin, ppos)
 | 
				
			||||||
	local obj = ray:next()
 | 
						local obj = ray:next()
 | 
				
			||||||
	-- found nothing
 | 
						-- found nothing
 | 
				
			||||||
	if obj == nil then return false end
 | 
						if obj == nil then return false end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -165,7 +165,7 @@ local function parse_config(player, particles)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		-- correct spawn coordinates to adjust for player movement
 | 
							-- correct spawn coordinates to adjust for player movement
 | 
				
			||||||
		if config.adjust_for_velocity then
 | 
							if config.adjust_for_velocity then
 | 
				
			||||||
			local velocity = player:get_player_velocity()
 | 
								local velocity = player:get_velocity()
 | 
				
			||||||
			config.minpos = vector.add(config.minpos, velocity)
 | 
								config.minpos = vector.add(config.minpos, velocity)
 | 
				
			||||||
			config.maxpos = vector.add(config.maxpos, velocity)
 | 
								config.maxpos = vector.add(config.maxpos, velocity)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								init.lua
									
									
									
									
									
								
							@@ -41,11 +41,25 @@ climate_mod.settings = {
 | 
				
			|||||||
    particle_count = get_setting_number("particle_count", 1),
 | 
					    particle_count = get_setting_number("particle_count", 1),
 | 
				
			||||||
    tick_speed = get_setting_number("tick_speed", 1),
 | 
					    tick_speed = get_setting_number("tick_speed", 1),
 | 
				
			||||||
    volume = get_setting_number("volume", 1),
 | 
					    volume = get_setting_number("volume", 1),
 | 
				
			||||||
	ceiling_checks	= get_setting_number("ceiling_checks", 10),
 | 
					    ceiling_checks = get_setting_number("ceiling_checks", 10)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
climate_mod.i18n = minetest.get_translator("climate_api")
 | 
					climate_mod.i18n = minetest.get_translator("climate_api")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- attempt to disable MTG weather mod
 | 
				
			||||||
 | 
					if climate_mod.settings.skybox and minetest.get_modpath("weather") then
 | 
				
			||||||
 | 
					    if weather ~= nil and weather.get ~= nil then
 | 
				
			||||||
 | 
					        weather.get = function(player)
 | 
				
			||||||
 | 
					            return {}
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					    elseif minetest.settings:get_bool("enable_weather") then
 | 
				
			||||||
 | 
					        -- old version with no API support
 | 
				
			||||||
 | 
					        -- warn about clouds being overriden by MTG weather
 | 
				
			||||||
 | 
					        minetest.log("warning", "[Regional Weather] " ..
 | 
				
			||||||
 | 
					            climate_mod.i18n("Disable MTG weather for the best experience. Check the forum for more information."))
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- initialize empty registers
 | 
					-- initialize empty registers
 | 
				
			||||||
climate_mod.weathers = {}
 | 
					climate_mod.weathers = {}
 | 
				
			||||||
climate_mod.effects = {}
 | 
					climate_mod.effects = {}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,3 @@
 | 
				
			|||||||
local mod_player_monoids = minetest.get_modpath("player_monoids") ~= nil
 | 
					 | 
				
			||||||
local mod_playerphysics = minetest.get_modpath("playerphysics") ~= nil
 | 
					 | 
				
			||||||
local mod_pova = minetest.get_modpath("pova") ~= nil
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local utility = {}
 | 
					local utility = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function utility.rangelim(value, min, max)
 | 
					function utility.rangelim(value, min, max)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,7 @@ minetest.register_chatcommand("weather", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- set base heat to increase or decrease global climate temperatures
 | 
					-- set base heat to increase or decrease global climate temperatures
 | 
				
			||||||
minetest.register_chatcommand("set_base_heat", {
 | 
					minetest.register_chatcommand("set_base_heat", {
 | 
				
			||||||
	params = "<heat>",
 | 
						params = S("<heat>"),
 | 
				
			||||||
	description = S("Override the weather algorithm's base heat"),
 | 
						description = S("Override the weather algorithm's base heat"),
 | 
				
			||||||
	privs = { weather = true },
 | 
						privs = { weather = true },
 | 
				
			||||||
	func = function(playername, param)
 | 
						func = function(playername, param)
 | 
				
			||||||
@@ -73,7 +73,7 @@ minetest.register_chatcommand("set_base_heat", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- override global heat levels with given value
 | 
					-- override global heat levels with given value
 | 
				
			||||||
minetest.register_chatcommand("set_heat", {
 | 
					minetest.register_chatcommand("set_heat", {
 | 
				
			||||||
	params = "<heat>",
 | 
						params = S("<heat>"),
 | 
				
			||||||
	description = S("Override the weather algorithm's heat"),
 | 
						description = S("Override the weather algorithm's heat"),
 | 
				
			||||||
	privs = { weather = true },
 | 
						privs = { weather = true },
 | 
				
			||||||
	func = function(playername, param)
 | 
						func = function(playername, param)
 | 
				
			||||||
@@ -93,7 +93,7 @@ minetest.register_chatcommand("set_heat", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- set base heat to increase or decrease global climate humidity
 | 
					-- set base heat to increase or decrease global climate humidity
 | 
				
			||||||
minetest.register_chatcommand("set_base_humidity", {
 | 
					minetest.register_chatcommand("set_base_humidity", {
 | 
				
			||||||
	params = "<humidity>",
 | 
						params = S("<humidity>"),
 | 
				
			||||||
	description = S("Override the weather algorithm's base humidity"),
 | 
						description = S("Override the weather algorithm's base humidity"),
 | 
				
			||||||
	privs = { weather = true },
 | 
						privs = { weather = true },
 | 
				
			||||||
	func = function(playername, param)
 | 
						func = function(playername, param)
 | 
				
			||||||
@@ -109,7 +109,7 @@ minetest.register_chatcommand("set_base_humidity", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- override global humidity with given value
 | 
					-- override global humidity with given value
 | 
				
			||||||
minetest.register_chatcommand("set_humidity", {
 | 
					minetest.register_chatcommand("set_humidity", {
 | 
				
			||||||
	params = "<humidity>",
 | 
						params = S("<humidity>"),
 | 
				
			||||||
	description = S("Override the weather algorithm's humidity"),
 | 
						description = S("Override the weather algorithm's humidity"),
 | 
				
			||||||
	privs = { weather = true },
 | 
						privs = { weather = true },
 | 
				
			||||||
	func = function(playername, param)
 | 
						func = function(playername, param)
 | 
				
			||||||
@@ -129,7 +129,7 @@ minetest.register_chatcommand("set_humidity", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- override wind direction and speed with given values
 | 
					-- override wind direction and speed with given values
 | 
				
			||||||
minetest.register_chatcommand("set_wind", {
 | 
					minetest.register_chatcommand("set_wind", {
 | 
				
			||||||
	params = "<wind>",
 | 
						params = S("<wind>"),
 | 
				
			||||||
	description = S("Override the weather algorithm's windspeed"),
 | 
						description = S("Override the weather algorithm's windspeed"),
 | 
				
			||||||
	privs = { weather = true },
 | 
						privs = { weather = true },
 | 
				
			||||||
	func = function(playername, param)
 | 
						func = function(playername, param)
 | 
				
			||||||
@@ -171,7 +171,7 @@ minetest.register_chatcommand("weather_settings", {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- force a weather preset or disable it
 | 
					-- force a weather preset or disable it
 | 
				
			||||||
minetest.register_chatcommand("set_weather", {
 | 
					minetest.register_chatcommand("set_weather", {
 | 
				
			||||||
	params ="<weather> <status>",
 | 
						params = S("<weather> <status>"),
 | 
				
			||||||
	description = S("Turn the specified weather preset on or off for all players or reset it to automatic"),
 | 
						description = S("Turn the specified weather preset on or off for all players or reset it to automatic"),
 | 
				
			||||||
	privs = { weather = true },
 | 
						privs = { weather = true },
 | 
				
			||||||
	func = function(playername, param)
 | 
						func = function(playername, param)
 | 
				
			||||||
@@ -230,3 +230,17 @@ minetest.register_chatcommand("weather_influences", {
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- used to debug downfall
 | 
				
			||||||
 | 
					minetest.register_chatcommand("explain_humidity", {
 | 
				
			||||||
 | 
						description = S("Explains how the humidity value got calculated"),
 | 
				
			||||||
 | 
						func = function(playername)
 | 
				
			||||||
 | 
							local base = climate_mod.settings.humidity
 | 
				
			||||||
 | 
							local biome = minetest.get_humidity((minetest.get_player_by_name(playername)):get_pos())
 | 
				
			||||||
 | 
							local random = climate_mod.state:get_float("humidity_random");
 | 
				
			||||||
 | 
							local random_base = climate_mod.state:get_float("humidity_base");
 | 
				
			||||||
 | 
							minetest.chat_send_player(playername, dump2(base, "base"))
 | 
				
			||||||
 | 
							minetest.chat_send_player(playername, dump2(biome, "biome"))
 | 
				
			||||||
 | 
							minetest.chat_send_player(playername, dump2(random, "random"))
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ function environment.get_heat(pos)
 | 
				
			|||||||
	local height = climate_api.utility.rangelim((-pos.y + 10) / 15, -10, 10)
 | 
						local height = climate_api.utility.rangelim((-pos.y + 10) / 15, -10, 10)
 | 
				
			||||||
	local time = climate_api.utility.normalized_cycle(minetest.get_timeofday()) * 0.6 + 0.7
 | 
						local time = climate_api.utility.normalized_cycle(minetest.get_timeofday()) * 0.6 + 0.7
 | 
				
			||||||
	local random = climate_mod.state:get_float("heat_random");
 | 
						local random = climate_mod.state:get_float("heat_random");
 | 
				
			||||||
	return (base + biome + height) * time * random
 | 
						return base + ((biome + height) * time * random)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function environment.get_humidity(pos)
 | 
					function environment.get_humidity(pos)
 | 
				
			||||||
@@ -19,8 +19,7 @@ function environment.get_humidity(pos)
 | 
				
			|||||||
	local base = climate_mod.settings.humidity
 | 
						local base = climate_mod.settings.humidity
 | 
				
			||||||
	local biome = minetest.get_humidity(pos)
 | 
						local biome = minetest.get_humidity(pos)
 | 
				
			||||||
	local random = climate_mod.state:get_float("humidity_random");
 | 
						local random = climate_mod.state:get_float("humidity_random");
 | 
				
			||||||
	local random_base = climate_mod.state:get_float("humidity_base");
 | 
						return base + ((biome * 0.7 + 40 * 0.3) * random)
 | 
				
			||||||
	return (base + biome * 0.7 + random_base * 0.3) * random
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function environment.get_wind(pos)
 | 
					function environment.get_wind(pos)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ climate_api.register_influence("humidity",
 | 
				
			|||||||
	climate_api.environment.get_humidity
 | 
						climate_api.environment.get_humidity
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
climate_api.register_influence("base_humidity",
 | 
					climate_api.register_influence("biome_humidity",
 | 
				
			||||||
	minetest.get_humidity
 | 
						minetest.get_humidity
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,13 +55,15 @@ end)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
climate_api.register_influence("daylight", function(pos)
 | 
					climate_api.register_influence("daylight", function(pos)
 | 
				
			||||||
	pos = vector.add(pos, {x = 0, y = 1, z = 0})
 | 
						pos = vector.add(pos, {x = 0, y = 1, z = 0})
 | 
				
			||||||
	return minetest.get_node_light(pos, 0.5) or 0
 | 
						return minetest.get_natural_light(pos, 0.5) or 0
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
climate_api.register_influence("indoors", function(pos)
 | 
					climate_api.register_influence("indoors", function(pos)
 | 
				
			||||||
	pos = vector.add(pos, {x = 0, y = 1, z = 0})
 | 
						pos = vector.add(pos, {x = 0, y = 1, z = 0})
 | 
				
			||||||
	local daylight = minetest.get_node_light(pos, 0.5) or 0
 | 
						local daylight = minetest.get_natural_light(pos, 0.5) or 0
 | 
				
			||||||
	if daylight < 15 then return true end
 | 
						-- max light is 15 but allow adjacent nodes to still be outdoors
 | 
				
			||||||
 | 
						-- to reduce effect switching on and off when walking underneath single nodes
 | 
				
			||||||
 | 
						if daylight < 14 then return true end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i = 1, climate_mod.settings.ceiling_checks do
 | 
						for i = 1, climate_mod.settings.ceiling_checks do
 | 
				
			||||||
		local lpos = vector.add(pos, {x = 0, y = i, z = 0})
 | 
							local lpos = vector.add(pos, {x = 0, y = i, z = 0})
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								lib/main.lua
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								lib/main.lua
									
									
									
									
									
								
							@@ -1,18 +1,12 @@
 | 
				
			|||||||
local GSCYCLE			=  0.03	* climate_mod.settings.tick_speed	-- only process event loop after this amount of time
 | 
					local GSCYCLE = 0.06 * climate_mod.settings.tick_speed	-- only process event loop after this amount of time
 | 
				
			||||||
local WORLD_CYCLE = 30.00 * climate_mod.settings.tick_speed	-- only update global environment influences after this amount of time
 | 
					local WORLD_CYCLE = 30.00 * climate_mod.settings.tick_speed	-- only update global environment influences after this amount of time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function is_connected(playername)
 | 
					 | 
				
			||||||
	local connected = minetest.get_connected_players()
 | 
					 | 
				
			||||||
	for _, player in ipairs(connected) do
 | 
					 | 
				
			||||||
		local name = player:get_player_name()
 | 
					 | 
				
			||||||
		if playername == name then return true end
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	return false
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local gs_timer = 0
 | 
					local gs_timer = 0
 | 
				
			||||||
local world_timer = 0
 | 
					local world_timer = 0
 | 
				
			||||||
minetest.register_globalstep(function(dtime)
 | 
					minetest.register_globalstep(function(dtime)
 | 
				
			||||||
 | 
						local player_list = minetest.get_connected_players()
 | 
				
			||||||
 | 
						if #player_list == 0 then return end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gs_timer = gs_timer + dtime
 | 
						gs_timer = gs_timer + dtime
 | 
				
			||||||
	world_timer = world_timer + dtime
 | 
						world_timer = world_timer + dtime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -29,13 +23,13 @@ minetest.register_globalstep(function(dtime)
 | 
				
			|||||||
	-- skip weather changes for offline players
 | 
						-- skip weather changes for offline players
 | 
				
			||||||
	for effect, data in pairs(previous_effects) do
 | 
						for effect, data in pairs(previous_effects) do
 | 
				
			||||||
		for playername, _ in pairs(data) do
 | 
							for playername, _ in pairs(data) do
 | 
				
			||||||
			if not is_connected(playername) then
 | 
								if not minetest.get_player_by_name(playername) then
 | 
				
			||||||
				previous_effects[effect][playername] = nil
 | 
									previous_effects[effect][playername] = nil
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local current_effects = climate_mod.trigger.get_active_effects()
 | 
						local current_effects = climate_mod.trigger.get_active_effects(player_list)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for name, effect in pairs(climate_mod.effects) do
 | 
						for name, effect in pairs(climate_mod.effects) do
 | 
				
			||||||
		local cycle = climate_mod.cycles[name].timespan * climate_mod.settings.tick_speed
 | 
							local cycle = climate_mod.cycles[name].timespan * climate_mod.settings.tick_speed
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,5 @@
 | 
				
			|||||||
 | 
					local mod_lighting_monoid = minetest.get_modpath("lighting_monoid") ~= nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local default_sky = {
 | 
					local default_sky = {
 | 
				
			||||||
	sky_data = {
 | 
						sky_data = {
 | 
				
			||||||
		base_color = nil,
 | 
							base_color = nil,
 | 
				
			||||||
@@ -42,6 +44,10 @@ local default_sky = {
 | 
				
			|||||||
		count = 1000,
 | 
							count = 1000,
 | 
				
			||||||
		star_color = "#ebebff69",
 | 
							star_color = "#ebebff69",
 | 
				
			||||||
		scale = 1
 | 
							scale = 1
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						light_data = {
 | 
				
			||||||
 | 
							shadow_intensity = 0.33,
 | 
				
			||||||
 | 
							saturation = 1
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,6 +76,11 @@ local function set_skybox(playername, sky)
 | 
				
			|||||||
	player:set_moon(sky.moon_data)
 | 
						player:set_moon(sky.moon_data)
 | 
				
			||||||
	player:set_sun(sky.sun_data)
 | 
						player:set_sun(sky.sun_data)
 | 
				
			||||||
	player:set_stars(sky.star_data)
 | 
						player:set_stars(sky.star_data)
 | 
				
			||||||
 | 
						local lighting = {
 | 
				
			||||||
 | 
							shadows = { intensity = sky.light_data.shadow_intensity },
 | 
				
			||||||
 | 
							saturation = sky.light_data.saturation
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						lighting_monoid:add_change(player, lighting, "climate_api:merged_lighting")
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function skybox.update(playername)
 | 
					function skybox.update(playername)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,6 @@ soundloop.play = function(player, sound, fade)
 | 
				
			|||||||
	if sounds[player] == nil then sounds[player] = {} end
 | 
						if sounds[player] == nil then sounds[player] = {} end
 | 
				
			||||||
	if sounds[player][sound.name] == nil then
 | 
						if sounds[player][sound.name] == nil then
 | 
				
			||||||
		step = sound.gain / fade
 | 
							step = sound.gain / fade
 | 
				
			||||||
		start_gain = 0
 | 
					 | 
				
			||||||
	elseif sounds[player][sound.name] ~= sound.gain then
 | 
						elseif sounds[player][sound.name] ~= sound.gain then
 | 
				
			||||||
		minetest.sound_stop(sounds[player][sound.name].handle)
 | 
							minetest.sound_stop(sounds[player][sound.name].handle)
 | 
				
			||||||
		start_gain = sounds[player][sound.name].gain
 | 
							start_gain = sounds[player][sound.name].gain
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ function trigger.get_global_environment()
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function trigger.get_position_environment(pos)
 | 
					function trigger.get_position_environment(pos)
 | 
				
			||||||
	local env = table.copy(climate_mod.global_environment)
 | 
						local env = trigger.get_global_environment()
 | 
				
			||||||
	for influence, func in pairs(climate_mod.influences) do
 | 
						for influence, func in pairs(climate_mod.influences) do
 | 
				
			||||||
		env[influence] = func(pos)
 | 
							env[influence] = func(pos)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
@@ -68,7 +68,7 @@ local function is_weather_active(player, weather, env)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function get_weather_effects(player, weather_config, env)
 | 
					local function get_weather_effects(player, weather_config, env)
 | 
				
			||||||
	local config = {}
 | 
						local config
 | 
				
			||||||
	local effects = {}
 | 
						local effects = {}
 | 
				
			||||||
	if type(weather_config.effects) == "function" then
 | 
						if type(weather_config.effects) == "function" then
 | 
				
			||||||
		config = weather_config.effects(env)
 | 
							config = weather_config.effects(env)
 | 
				
			||||||
@@ -83,24 +83,19 @@ local function get_weather_effects(player, weather_config, env)
 | 
				
			|||||||
	return effects
 | 
						return effects
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function trigger.get_active_effects()
 | 
					function trigger.get_active_effects(players)
 | 
				
			||||||
	local environments = {}
 | 
						local environments = {}
 | 
				
			||||||
	for _, player in ipairs(minetest.get_connected_players()) do
 | 
						local effects = {}
 | 
				
			||||||
		local playername = player:get_player_name()
 | 
						climate_mod.current_weather = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for _, player in ipairs(players) do
 | 
				
			||||||
 | 
							local pname = player:get_player_name()
 | 
				
			||||||
		local hp = player:get_hp()
 | 
							local hp = player:get_hp()
 | 
				
			||||||
		-- skip weather presets for dead players
 | 
							-- skip weather presets for dead players
 | 
				
			||||||
		if hp ~= nil and hp > 0 then
 | 
							if hp ~= nil and hp > 0 then
 | 
				
			||||||
			environments[playername] = trigger.get_player_environment(player)
 | 
								local env = trigger.get_player_environment(player)
 | 
				
			||||||
		end
 | 
								environments[pname] = env
 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local effects = {}
 | 
					 | 
				
			||||||
	climate_mod.current_weather = {}
 | 
					 | 
				
			||||||
			for wname, wconfig in pairs(climate_mod.weathers) do
 | 
								for wname, wconfig in pairs(climate_mod.weathers) do
 | 
				
			||||||
		for _, player in ipairs(minetest.get_connected_players()) do
 | 
					 | 
				
			||||||
			local pname = player:get_player_name()
 | 
					 | 
				
			||||||
			local env = environments[pname]
 | 
					 | 
				
			||||||
			if env ~= nil then
 | 
					 | 
				
			||||||
				if is_weather_active(player, wname, env) then
 | 
									if is_weather_active(player, wname, env) then
 | 
				
			||||||
					if climate_mod.current_weather[pname] == nil then
 | 
										if climate_mod.current_weather[pname] == nil then
 | 
				
			||||||
						climate_mod.current_weather[pname] = {}
 | 
											climate_mod.current_weather[pname] = {}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,9 +6,8 @@ local WIND_SCALE = 2
 | 
				
			|||||||
local HEAT_SPREAD = 400
 | 
					local HEAT_SPREAD = 400
 | 
				
			||||||
local HEAT_SCALE = 0.3
 | 
					local HEAT_SCALE = 0.3
 | 
				
			||||||
local HUMIDITY_SPREAD = 150
 | 
					local HUMIDITY_SPREAD = 150
 | 
				
			||||||
local HUMIDITY_SCALE = 0.5
 | 
					local HUMIDITY_SCALE = 1
 | 
				
			||||||
local HUMIDITY_BASE_SPREAD = 800
 | 
					local HUMIDITY_TIMESCALE = 1
 | 
				
			||||||
local HUMIDITY_BASE_SCALE = 40
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
local nobj_wind_x
 | 
					local nobj_wind_x
 | 
				
			||||||
local nobj_wind_z
 | 
					local nobj_wind_z
 | 
				
			||||||
@@ -47,23 +46,14 @@ local pn_heat = {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local pn_humidity = {
 | 
					local pn_humidity = {
 | 
				
			||||||
	offset = 0,
 | 
						offset = 1,
 | 
				
			||||||
	scale = HUMIDITY_SCALE,
 | 
						scale = HUMIDITY_SCALE,
 | 
				
			||||||
	spread = {x = HUMIDITY_SPREAD, y = HUMIDITY_SPREAD, z = HUMIDITY_SPREAD},
 | 
						spread = {x = HUMIDITY_SPREAD, y = HUMIDITY_SPREAD, z = HUMIDITY_SPREAD},
 | 
				
			||||||
	seed = 8374061,
 | 
						seed = 8374061,
 | 
				
			||||||
	octaves = 2,
 | 
						octaves = 2,
 | 
				
			||||||
	persist = 0.5,
 | 
						persist = 0.5,
 | 
				
			||||||
	lacunarity = 2
 | 
						lacunarity = 2,
 | 
				
			||||||
}
 | 
						flags = "noeased"
 | 
				
			||||||
 | 
					 | 
				
			||||||
local pn_humidity_base = {
 | 
					 | 
				
			||||||
	offset = 50,
 | 
					 | 
				
			||||||
	scale = HUMIDITY_BASE_SCALE,
 | 
					 | 
				
			||||||
	spread = {x = HUMIDITY_BASE_SPREAD, y = HUMIDITY_BASE_SPREAD, z = HUMIDITY_BASE_SPREAD},
 | 
					 | 
				
			||||||
	seed = 3803465,
 | 
					 | 
				
			||||||
	octaves = 2,
 | 
					 | 
				
			||||||
	persist = 0.5,
 | 
					 | 
				
			||||||
	lacunarity = 2
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function update_wind(timer)
 | 
					local function update_wind(timer)
 | 
				
			||||||
@@ -83,11 +73,8 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local function update_humidity(timer)
 | 
					local function update_humidity(timer)
 | 
				
			||||||
	nobj_humidity = nobj_humidity or minetest.get_perlin(pn_humidity)
 | 
						nobj_humidity = nobj_humidity or minetest.get_perlin(pn_humidity)
 | 
				
			||||||
	local n_humidity = nobj_humidity:get_2d({x = timer, y = 0})
 | 
						local n_humidity = nobj_humidity:get_2d({x = timer * HUMIDITY_TIMESCALE, y = 0})
 | 
				
			||||||
	climate_mod.state:set_float("humidity_random", n_humidity)
 | 
						climate_mod.state:set_float("humidity_random", n_humidity)
 | 
				
			||||||
	nobj_humidity_base = nobj_humidity_base or minetest.get_perlin(pn_humidity_base)
 | 
					 | 
				
			||||||
	local n_humidity_base = nobj_humidity_base:get_2d({x = timer, y = 0})
 | 
					 | 
				
			||||||
	climate_mod.state:set_float("humidity_base", n_humidity_base)
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function world.update_status(timer)
 | 
					function world.update_status(timer)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@ scorching=stechend heiße
 | 
				
			|||||||
pleasant=angenehme
 | 
					pleasant=angenehme
 | 
				
			||||||
chilly=kühle
 | 
					chilly=kühle
 | 
				
			||||||
It is a @1 @2 right now and humidity is at @3%.=Es sind gerade @1 @2 und die Luftfeuchtigkeit liegt bei @3%.
 | 
					It is a @1 @2 right now and humidity is at @3%.=Es sind gerade @1 @2 und die Luftfeuchtigkeit liegt bei @3%.
 | 
				
			||||||
 | 
					<heat>=
 | 
				
			||||||
Override the weather algorithm's base heat=Überschreibe die Standard-Temperatur
 | 
					Override the weather algorithm's base heat=Überschreibe die Standard-Temperatur
 | 
				
			||||||
Provide a number to modify the base heat=Gebe eine Zahl an, um die Standard-Temperatur anzupassen
 | 
					Provide a number to modify the base heat=Gebe eine Zahl an, um die Standard-Temperatur anzupassen
 | 
				
			||||||
Base heat changed=Die Standard-Temperatur wurde geändert
 | 
					Base heat changed=Die Standard-Temperatur wurde geändert
 | 
				
			||||||
@@ -15,6 +16,7 @@ Override the weather algorithm's heat=Überschreibe die tatsächliche Temperatur
 | 
				
			|||||||
Provide a number to modify the heat=Gebe eine Zahl an, um die Temperatur anzupassen
 | 
					Provide a number to modify the heat=Gebe eine Zahl an, um die Temperatur anzupassen
 | 
				
			||||||
Heat value reset=Die Temperatur wurde zurückgesetzt
 | 
					Heat value reset=Die Temperatur wurde zurückgesetzt
 | 
				
			||||||
Heat value changed=Die Temperatur wurde geändert
 | 
					Heat value changed=Die Temperatur wurde geändert
 | 
				
			||||||
 | 
					<humidity>=
 | 
				
			||||||
Override the weather algorithm's base humidity=Überschreibe die Standard-Luftfeuchtigkeit
 | 
					Override the weather algorithm's base humidity=Überschreibe die Standard-Luftfeuchtigkeit
 | 
				
			||||||
Provide a number to modify the base humidity=Gebe eine Zahl an, um die Standard-Temperatur anzupassen
 | 
					Provide a number to modify the base humidity=Gebe eine Zahl an, um die Standard-Temperatur anzupassen
 | 
				
			||||||
Base humidity changed=Die Standard-Luftfeuchtigkeit wurde geändert
 | 
					Base humidity changed=Die Standard-Luftfeuchtigkeit wurde geändert
 | 
				
			||||||
@@ -22,6 +24,7 @@ Override the weather algorithm's humidity=Überschreibe die tatsächliche Luftfe
 | 
				
			|||||||
Provide a number to modify the humidity=Gebe eine Zahl an, um die Luftfeuchtigkeit anzupassen
 | 
					Provide a number to modify the humidity=Gebe eine Zahl an, um die Luftfeuchtigkeit anzupassen
 | 
				
			||||||
Humidity value reset=Die Luftfeuchtigkeit wurde zurückgesetzt
 | 
					Humidity value reset=Die Luftfeuchtigkeit wurde zurückgesetzt
 | 
				
			||||||
Humidity value changed=Die Luftfeuchtigkeit wurde geändert
 | 
					Humidity value changed=Die Luftfeuchtigkeit wurde geändert
 | 
				
			||||||
 | 
					<wind>=
 | 
				
			||||||
Override the weather algorithm's windspeed=Überschreibe die Windgeschwindigkeit
 | 
					Override the weather algorithm's windspeed=Überschreibe die Windgeschwindigkeit
 | 
				
			||||||
Provide a vector of two numbers to modify the wind=Gebe einen Vektor aus zwei Zahlen an, um die Windgeschwindigkeit anzupassen
 | 
					Provide a vector of two numbers to modify the wind=Gebe einen Vektor aus zwei Zahlen an, um die Windgeschwindigkeit anzupassen
 | 
				
			||||||
Wind reset=Der Wind wurde zurückgesetzt
 | 
					Wind reset=Der Wind wurde zurückgesetzt
 | 
				
			||||||
@@ -29,6 +32,7 @@ Invalid wind configuration=Fehlerhafte Windkonfiguration
 | 
				
			|||||||
Wind changed=Der Wind wurde geändert
 | 
					Wind changed=Der Wind wurde geändert
 | 
				
			||||||
Print the active Climate API configuration=Betrachte die Einstellungen für Climate API
 | 
					Print the active Climate API configuration=Betrachte die Einstellungen für Climate API
 | 
				
			||||||
Current Settings=Aktuelle Einstellungen
 | 
					Current Settings=Aktuelle Einstellungen
 | 
				
			||||||
 | 
					<weather> <status>=
 | 
				
			||||||
Turn the specified weather preset on or off for all players or reset it to automatic=Schalte für alle Spieler die angegebene Wetterklasse an, aus oder schalte sie auf automatisch
 | 
					Turn the specified weather preset on or off for all players or reset it to automatic=Schalte für alle Spieler die angegebene Wetterklasse an, aus oder schalte sie auf automatisch
 | 
				
			||||||
Unknown weather preset=Unbekannte Wetterklasse
 | 
					Unknown weather preset=Unbekannte Wetterklasse
 | 
				
			||||||
Invalid weather status. Set the preset to either on, off or auto.=Unbekannter Status. Setze die Wetterklasse entweder auf on, off oder auto
 | 
					Invalid weather status. Set the preset to either on, off or auto.=Unbekannter Status. Setze die Wetterklasse entweder auf on, off oder auto
 | 
				
			||||||
@@ -37,3 +41,4 @@ Prints which weather presets are enforced or disabled=Betrachte, welche Wetterkl
 | 
				
			|||||||
Current activation rules:=Aktuelle Aktivierungsregeln
 | 
					Current activation rules:=Aktuelle Aktivierungsregeln
 | 
				
			||||||
Prints which weather influences cause your current weather=Betrachte, welche Umwelteinflüsse das aktuelle Wetter hervorrufen
 | 
					Prints which weather influences cause your current weather=Betrachte, welche Umwelteinflüsse das aktuelle Wetter hervorrufen
 | 
				
			||||||
Current influences rules:=Aktuelle Einflussfaktoren
 | 
					Current influences rules:=Aktuelle Einflussfaktoren
 | 
				
			||||||
 | 
					Explains how the humidity value got calculated=
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										44
									
								
								locale/climate_api.eo.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								locale/climate_api.eo.tr
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					# textdomain: climate_api
 | 
				
			||||||
 | 
					Make changes to the current weather=Ŝanĝi la nunan veteron
 | 
				
			||||||
 | 
					Display weather information=Montri veterajn informojn
 | 
				
			||||||
 | 
					The following weather presets are active for you:=La jenaj veteragordoj estas ŝaltitaj por vi:
 | 
				
			||||||
 | 
					Your sky is clear. No weather presets are currently active.=La suno brilas. Neniu veteragordo estas ŝaltita.
 | 
				
			||||||
 | 
					As a result, the following environment effects are applied:=Pro tio, la jenaj efikoj estas aktivaj:
 | 
				
			||||||
 | 
					scorching=Varmas
 | 
				
			||||||
 | 
					pleasant=Komfortas
 | 
				
			||||||
 | 
					chilly=Malvarmas
 | 
				
			||||||
 | 
					It is a @1 @2 right now and humidity is at @3%.=@1 je @2 ĝuste nun, kun aermalsekeco je @3 gradoj.
 | 
				
			||||||
 | 
					<heat>=<varm>
 | 
				
			||||||
 | 
					Override the weather algorithm's base heat=Anstataŭigi la bazan varmecon de la vetera algoritmo
 | 
				
			||||||
 | 
					Provide a number to modify the base heat=Doni nombron anstataŭiguntan la bazan varmecon
 | 
				
			||||||
 | 
					Base heat changed=Baza varmeco ŝanĝita
 | 
				
			||||||
 | 
					Override the weather algorithm's heat=Anstataŭigi la varmecon de la vetera algoritmo
 | 
				
			||||||
 | 
					Provide a number to modify the heat=Doni nombron anstataŭiguntan la varmecon
 | 
				
			||||||
 | 
					Heat value reset=Varmeco malagordita
 | 
				
			||||||
 | 
					Heat value changed=Varmeco ŝanĝita
 | 
				
			||||||
 | 
					<humidity>=<aermalsek>
 | 
				
			||||||
 | 
					Override the weather algorithm's base humidity=Anstataŭigi la bazan aermalsekecon de la vetera algoritmo
 | 
				
			||||||
 | 
					Provide a number to modify the base humidity=Doni nombron anstataŭiguntan la bazan aermalsekecon
 | 
				
			||||||
 | 
					Base humidity changed=Baza aermalsekeco ŝanĝita
 | 
				
			||||||
 | 
					Override the weather algorithm's humidity=Anstataŭigi la aermalsekecon de la vetera algoritmo
 | 
				
			||||||
 | 
					Provide a number to modify the humidity=Doni nombron anstataŭiguntan la aermalsekecon
 | 
				
			||||||
 | 
					Humidity value reset=Aermalsekeco malagordita
 | 
				
			||||||
 | 
					Humidity value changed=Aermalsekeca ŝanĝita
 | 
				
			||||||
 | 
					<wind>=<vent>
 | 
				
			||||||
 | 
					Override the weather algorithm's windspeed=Anstataŭigi la ventforton de la vetera algoritmo
 | 
				
			||||||
 | 
					Provide a vector of two numbers to modify the wind=Doni nombroparon anstataŭiguntan la ventoforton
 | 
				
			||||||
 | 
					Wind reset=Ventoforto malagordita
 | 
				
			||||||
 | 
					Invalid wind configuration=Nevalida ventagordo
 | 
				
			||||||
 | 
					Wind changed=Vento ŝanĝita
 | 
				
			||||||
 | 
					Print the active Climate API configuration=Presi la nunan agordon por Climate API
 | 
				
			||||||
 | 
					Current Settings=Nunaj Agordoj
 | 
				
			||||||
 | 
					<weather> <status>=<veter> <ŝaltec>
 | 
				
			||||||
 | 
					Turn the specified weather preset on or off for all players or reset it to automatic=Agordi veteragordon por ĉiuj ludantoj: «on» (ŝalti), «off» (malŝalti), «reset» (malfari)
 | 
				
			||||||
 | 
					Unknown weather preset=Nekonata veteragordo
 | 
				
			||||||
 | 
					Invalid weather status. Set the preset to either on, off or auto.=Nevalida veterostato. Agordu la veteragordon al «on» (ŝalti), «off» (malŝalti), aŭ «auto» (memagi).
 | 
				
			||||||
 | 
					Weather @1 successfully set to @2=Vetero @1 sukcese agordita al @2
 | 
				
			||||||
 | 
					Prints which weather presets are enforced or disabled=Listigas veterstatojn laŭ ŝaltiteco
 | 
				
			||||||
 | 
					Current activation rules:=Nunaj aktivigaj reguloj:
 | 
				
			||||||
 | 
					Prints which weather influences cause your current weather=Presas la influojn kiuj venigis la nunan veteron
 | 
				
			||||||
 | 
					Current influences rules:=Nunaj influaj reguloj:
 | 
				
			||||||
 | 
					Explains how the humidity value got calculated=Klarigas kiel la aermalseka valoro kalkuliĝis
 | 
				
			||||||
@@ -8,6 +8,7 @@ scorching=
 | 
				
			|||||||
pleasant=
 | 
					pleasant=
 | 
				
			||||||
chilly=
 | 
					chilly=
 | 
				
			||||||
It is a @1 @2 right now and humidity is at @3%.=
 | 
					It is a @1 @2 right now and humidity is at @3%.=
 | 
				
			||||||
 | 
					<heat>=
 | 
				
			||||||
Override the weather algorithm's base heat=
 | 
					Override the weather algorithm's base heat=
 | 
				
			||||||
Provide a number to modify the base heat=
 | 
					Provide a number to modify the base heat=
 | 
				
			||||||
Base heat changed=
 | 
					Base heat changed=
 | 
				
			||||||
@@ -15,6 +16,7 @@ Override the weather algorithm's heat=
 | 
				
			|||||||
Provide a number to modify the heat=
 | 
					Provide a number to modify the heat=
 | 
				
			||||||
Heat value reset=
 | 
					Heat value reset=
 | 
				
			||||||
Heat value changed=
 | 
					Heat value changed=
 | 
				
			||||||
 | 
					<humidity>=
 | 
				
			||||||
Override the weather algorithm's base humidity=
 | 
					Override the weather algorithm's base humidity=
 | 
				
			||||||
Provide a number to modify the base humidity=
 | 
					Provide a number to modify the base humidity=
 | 
				
			||||||
Base humidity changed=
 | 
					Base humidity changed=
 | 
				
			||||||
@@ -22,6 +24,7 @@ Override the weather algorithm's humidity=
 | 
				
			|||||||
Provide a number to modify the humidity=
 | 
					Provide a number to modify the humidity=
 | 
				
			||||||
Humidity value reset=
 | 
					Humidity value reset=
 | 
				
			||||||
Humidity value changed=
 | 
					Humidity value changed=
 | 
				
			||||||
 | 
					<wind>=
 | 
				
			||||||
Override the weather algorithm's windspeed=
 | 
					Override the weather algorithm's windspeed=
 | 
				
			||||||
Provide a vector of two numbers to modify the wind=
 | 
					Provide a vector of two numbers to modify the wind=
 | 
				
			||||||
Wind reset=
 | 
					Wind reset=
 | 
				
			||||||
@@ -29,6 +32,7 @@ Invalid wind configuration=
 | 
				
			|||||||
Wind changed=
 | 
					Wind changed=
 | 
				
			||||||
Print the active Climate API configuration=
 | 
					Print the active Climate API configuration=
 | 
				
			||||||
Current Settings=
 | 
					Current Settings=
 | 
				
			||||||
 | 
					<weather> <status>=
 | 
				
			||||||
Turn the specified weather preset on or off for all players or reset it to automatic=
 | 
					Turn the specified weather preset on or off for all players or reset it to automatic=
 | 
				
			||||||
Unknown weather preset=
 | 
					Unknown weather preset=
 | 
				
			||||||
Invalid weather status. Set the preset to either on, off or auto.=
 | 
					Invalid weather status. Set the preset to either on, off or auto.=
 | 
				
			||||||
@@ -37,3 +41,4 @@ Prints which weather presets are enforced or disabled=
 | 
				
			|||||||
Current activation rules:=
 | 
					Current activation rules:=
 | 
				
			||||||
Prints which weather influences cause your current weather=
 | 
					Prints which weather influences cause your current weather=
 | 
				
			||||||
Current influences rules:=
 | 
					Current influences rules:=
 | 
				
			||||||
 | 
					Explains how the humidity value got calculated=
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								mod.conf
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								mod.conf
									
									
									
									
									
								
							@@ -1,8 +1,8 @@
 | 
				
			|||||||
name = climate_api
 | 
					name = climate_api
 | 
				
			||||||
title = Climate API
 | 
					title = Climate API
 | 
				
			||||||
author = TestificateMods
 | 
					author = TestificateMods
 | 
				
			||||||
release = 10001
 | 
					depends = lighting_monoid
 | 
				
			||||||
optional_depends = player_monoids, playerphysics, pova
 | 
					optional_depends = player_monoids, playerphysics, pova, weather
 | 
				
			||||||
description = """
 | 
					description = """
 | 
				
			||||||
A powerful engine for weather presets and visual effects.
 | 
					A powerful engine for weather presets and visual effects.
 | 
				
			||||||
Use the regional climate to set up different effects for different regions.
 | 
					Use the regional climate to set up different effects for different regions.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user