mirror of
https://github.com/t-affeldt/climate_api.git
synced 2025-06-30 07:20:48 +02:00
Improve wind position for particles, add command to set wind, improve wind influences
This commit is contained in:
@ -77,6 +77,32 @@ minetest.register_chatcommand("set_humidity", {
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("set_wind", {
|
||||
params = "<wind>",
|
||||
description = "Override the weather algorithm's windspeed",
|
||||
privs = { weather = true },
|
||||
func = function(playername, param)
|
||||
if param == nil or param == "" then
|
||||
minetest.chat_send_player(playername, "Provide a number to modify the base humidity")
|
||||
return
|
||||
end
|
||||
local arguments = {}
|
||||
for w in param:gmatch("%S+") do table.insert(arguments, w) end
|
||||
local wind_x = arguments[1]
|
||||
local wind_z = arguments[2]
|
||||
if wind_x == "auto" then
|
||||
climate_mod.forced_wind = nil
|
||||
else
|
||||
climate_mod.forced_wind = vector.new({
|
||||
x = tonumber(wind_x),
|
||||
y = 0,
|
||||
z = tonumber(wind_z)
|
||||
})
|
||||
end
|
||||
minetest.chat_send_player(playername, "Wind changed")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("weather_settings", {
|
||||
description = "Print the active Climate API configuration",
|
||||
func = function(playername)
|
||||
|
@ -6,7 +6,7 @@ local function get_heat_time()
|
||||
end
|
||||
|
||||
local function get_heat_calendar()
|
||||
-- European heat center in August instead of June
|
||||
-- heat center in August instead of June
|
||||
local day = minetest.get_day_count()
|
||||
local progression = ((day + 61) % 365) / 365
|
||||
return climate_api.utility.normalized_cycle(progression) * 0.6 + 0.7
|
||||
@ -35,6 +35,9 @@ function environment.get_humidity(pos)
|
||||
end
|
||||
|
||||
function environment.get_wind()
|
||||
if climate_mod.forced_wind ~= nil then
|
||||
return climate_mod.forced_wind
|
||||
end
|
||||
local wind_x = climate_mod.state:get_float("wind_x")
|
||||
local wind_z = climate_mod.state:get_float("wind_z")
|
||||
return vector.new({ x = wind_x, y = 0, z = wind_z })
|
||||
|
@ -13,17 +13,14 @@ climate_api.register_influence("biome", function(pos)
|
||||
end)
|
||||
|
||||
climate_api.register_influence("windspeed", function(_)
|
||||
local wind_x = climate_mod.state:get_float("wind_x")
|
||||
local wind_z = climate_mod.state:get_float("wind_z")
|
||||
return vector.length({x = wind_x, y = 0, z = wind_z})
|
||||
local wind = climate_api.environment.get_wind()
|
||||
return vector.length(wind)
|
||||
end)
|
||||
|
||||
climate_api.register_influence("wind_x", function(_)
|
||||
return climate_mod.state:get_float("wind_x")
|
||||
end)
|
||||
|
||||
climate_api.register_influence("wind_z", function(_)
|
||||
return climate_mod.state:get_float("wind_z")
|
||||
climate_api.register_influence("wind_yaw", function(_)
|
||||
local wind = climate_api.environment.get_wind()
|
||||
if vector.length(wind) == 0 then return 0 end
|
||||
return minetest.dir_to_yaw(wind)
|
||||
end)
|
||||
|
||||
climate_api.register_influence("height", function(pos)
|
||||
|
Reference in New Issue
Block a user