mirror of
https://github.com/t-affeldt/climate_api.git
synced 2024-12-22 08:50:37 +01:00
Improve wind position for particles, add command to set wind, improve wind influences
This commit is contained in:
parent
241a0a82c1
commit
a6cfca7745
@ -4,15 +4,11 @@
|
|||||||
- Find good values for weather conditions
|
- Find good values for weather conditions
|
||||||
- Make sure all weather presets are working
|
- Make sure all weather presets are working
|
||||||
|
|
||||||
## Required for Beta
|
|
||||||
- Ability to register environment conditions dynamically (like the heat)
|
|
||||||
|
|
||||||
## Planned for first release
|
## Planned for first release
|
||||||
- Write helpful README
|
- Write helpful README
|
||||||
- Set effects on player join
|
- Set effects on player join
|
||||||
- Improve value structures of particle and skybox effects
|
- Improve value structures of particle and skybox effects
|
||||||
- Make sounds adjust to changes by weather presets
|
- Make sounds adjust to changes by weather presets
|
||||||
- Ability to force set a wind speed via chat commands
|
|
||||||
|
|
||||||
## Nice to have
|
## Nice to have
|
||||||
- Write documentation on how to add weathers and effects
|
- Write documentation on how to add weathers and effects
|
||||||
@ -22,7 +18,6 @@
|
|||||||
- Make switches between effects more smooth
|
- Make switches between effects more smooth
|
||||||
- Adjust size of particle boxes based on player speed
|
- Adjust size of particle boxes based on player speed
|
||||||
- Create conditions for time of day, annual progression, biome filters
|
- Create conditions for time of day, annual progression, biome filters
|
||||||
- Support for sail boats mod
|
|
||||||
|
|
||||||
## Future Plans & Ideas
|
## Future Plans & Ideas
|
||||||
- Complete season system
|
- Complete season system
|
||||||
|
@ -11,18 +11,11 @@ end
|
|||||||
|
|
||||||
local function spawn_particles(player, particles)
|
local function spawn_particles(player, particles)
|
||||||
local ppos = player:getpos()
|
local ppos = player:getpos()
|
||||||
local wind_x = climate_mod.state:get_float("wind_x")
|
local wind = climate_api.environment.get_wind()
|
||||||
local wind_z = climate_mod.state:get_float("wind_z")
|
|
||||||
local wind = vector.new(wind_x, 0, wind_z)
|
|
||||||
local wind_pos = vector.multiply(wind, -1)
|
|
||||||
local wind_speed = vector.length(wind)
|
|
||||||
|
|
||||||
local amount = particles.amount * climate_mod.settings.particle_count
|
local amount = particles.amount * climate_mod.settings.particle_count
|
||||||
local texture = get_particle_texture(particles)
|
local texture = get_particle_texture(particles)
|
||||||
|
|
||||||
local minp = vector.add(vector.add(ppos, particles.min_pos), wind_pos)
|
|
||||||
local maxp = vector.add(vector.add(ppos, particles.max_pos), wind_pos)
|
|
||||||
|
|
||||||
local vel = vector.new({
|
local vel = vector.new({
|
||||||
x = wind.x,
|
x = wind.x,
|
||||||
y = -particles.falling_speed,
|
y = -particles.falling_speed,
|
||||||
@ -30,6 +23,14 @@ local function spawn_particles(player, particles)
|
|||||||
})
|
})
|
||||||
local acc = vector.new({x=0, y=0, z=0})
|
local acc = vector.new({x=0, y=0, z=0})
|
||||||
|
|
||||||
|
local wind_pos = vector.multiply(
|
||||||
|
vector.normalize(vel),
|
||||||
|
-vector.length(wind)
|
||||||
|
)
|
||||||
|
wind_pos.y = 0
|
||||||
|
local minp = vector.add(vector.add(ppos, particles.min_pos), wind_pos)
|
||||||
|
local maxp = vector.add(vector.add(ppos, particles.max_pos), wind_pos)
|
||||||
|
|
||||||
local exp = particles.exptime
|
local exp = particles.exptime
|
||||||
local vertical = math.abs(vector.normalize(vel).y) >= 0.6
|
local vertical = math.abs(vector.normalize(vel).y) >= 0.6
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ if not climate_mod.settings.skybox then return end
|
|||||||
|
|
||||||
local EFFECT_NAME = "climate_api:skybox"
|
local EFFECT_NAME = "climate_api:skybox"
|
||||||
|
|
||||||
|
local reset_data = {}
|
||||||
|
|
||||||
local function set_skybox(player, sky)
|
local function set_skybox(player, sky)
|
||||||
if not player.get_stars then return end
|
if not player.get_stars then return end
|
||||||
if sky.sky_data ~= nil then
|
if sky.sky_data ~= nil then
|
||||||
@ -16,14 +18,14 @@ local function set_skybox(player, sky)
|
|||||||
if sky.sun_data ~= nil then
|
if sky.sun_data ~= nil then
|
||||||
player:set_sun(sky.sun_data)
|
player:set_sun(sky.sun_data)
|
||||||
end
|
end
|
||||||
if sky.stars_data ~= nil then
|
if sky.star_data ~= nil then
|
||||||
player:set_sun(sky.stars_data)
|
player:set_stars(sky.stars_data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function remove_skybox(player)
|
local function remove_skybox(player)
|
||||||
if not player.get_stars then return end
|
if not player.get_stars then return end
|
||||||
player:set_sky({ type = "regular", clouds = true})
|
player:set_sky({ type = "regular", clouds = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handle_effect(player_data)
|
local function handle_effect(player_data)
|
||||||
|
4
init.lua
4
init.lua
@ -31,7 +31,8 @@ climate_mod.settings = {
|
|||||||
humidity = get_setting_number("humidity_base", 0),
|
humidity = get_setting_number("humidity_base", 0),
|
||||||
time_spread = get_setting_number("time_spread", 1),
|
time_spread = get_setting_number("time_spread", 1),
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
-- initiate empty registers
|
-- initiate empty registers
|
||||||
@ -42,6 +43,7 @@ climate_mod.influences = {}
|
|||||||
climate_mod.current_weather = {}
|
climate_mod.current_weather = {}
|
||||||
climate_mod.current_effects = {}
|
climate_mod.current_effects = {}
|
||||||
climate_mod.forced_weather = {}
|
climate_mod.forced_weather = {}
|
||||||
|
climate_mod.forced_wind = nil
|
||||||
|
|
||||||
-- import core API
|
-- import core API
|
||||||
climate_mod.state = dofile(modpath .. "/lib/datastorage.lua")
|
climate_mod.state = dofile(modpath .. "/lib/datastorage.lua")
|
||||||
|
@ -77,6 +77,32 @@ minetest.register_chatcommand("set_humidity", {
|
|||||||
end
|
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", {
|
minetest.register_chatcommand("weather_settings", {
|
||||||
description = "Print the active Climate API configuration",
|
description = "Print the active Climate API configuration",
|
||||||
func = function(playername)
|
func = function(playername)
|
||||||
|
@ -6,7 +6,7 @@ local function get_heat_time()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_heat_calendar()
|
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 day = minetest.get_day_count()
|
||||||
local progression = ((day + 61) % 365) / 365
|
local progression = ((day + 61) % 365) / 365
|
||||||
return climate_api.utility.normalized_cycle(progression) * 0.6 + 0.7
|
return climate_api.utility.normalized_cycle(progression) * 0.6 + 0.7
|
||||||
@ -35,6 +35,9 @@ function environment.get_humidity(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function environment.get_wind()
|
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_x = climate_mod.state:get_float("wind_x")
|
||||||
local wind_z = climate_mod.state:get_float("wind_z")
|
local wind_z = climate_mod.state:get_float("wind_z")
|
||||||
return vector.new({ x = wind_x, y = 0, z = 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)
|
end)
|
||||||
|
|
||||||
climate_api.register_influence("windspeed", function(_)
|
climate_api.register_influence("windspeed", function(_)
|
||||||
local wind_x = climate_mod.state:get_float("wind_x")
|
local wind = climate_api.environment.get_wind()
|
||||||
local wind_z = climate_mod.state:get_float("wind_z")
|
return vector.length(wind)
|
||||||
return vector.length({x = wind_x, y = 0, z = wind_z})
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
climate_api.register_influence("wind_x", function(_)
|
climate_api.register_influence("wind_yaw", function(_)
|
||||||
return climate_mod.state:get_float("wind_x")
|
local wind = climate_api.environment.get_wind()
|
||||||
end)
|
if vector.length(wind) == 0 then return 0 end
|
||||||
|
return minetest.dir_to_yaw(wind)
|
||||||
climate_api.register_influence("wind_z", function(_)
|
|
||||||
return climate_mod.state:get_float("wind_z")
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
climate_api.register_influence("height", function(pos)
|
climate_api.register_influence("height", function(pos)
|
||||||
|
@ -9,4 +9,5 @@ climate_api_humidity_base (Global base humidity) float 0
|
|||||||
climate_api_time_spread (Regulates how quickly the weather changes) float 1 0.1 10
|
climate_api_time_spread (Regulates how quickly the weather changes) float 1 0.1 10
|
||||||
climate_api_particle_count (Multiplicator for used particles) float 1 0.1 2
|
climate_api_particle_count (Multiplicator for used particles) float 1 0.1 2
|
||||||
climate_api_fahrenheit (Show degrees in Fahrenheit instead of Celsius) bool false
|
climate_api_fahrenheit (Show degrees in Fahrenheit instead of Celsius) bool false
|
||||||
climate_api_tick_speed (Update speed of weather effects) float 1 0.1 10
|
climate_api_tick_speed (Update speed of weather effects) float 1 0.1 10
|
||||||
|
climate_api_volume (Volume of sound effects) float 1 0 10
|
Loading…
Reference in New Issue
Block a user