Improve wind position for particles, add command to set wind, improve wind influences

This commit is contained in:
Till Affeldt 2020-04-18 11:12:47 +02:00
parent 241a0a82c1
commit a6cfca7745
8 changed files with 55 additions and 28 deletions

View File

@ -4,15 +4,11 @@
- Find good values for weather conditions
- Make sure all weather presets are working
## Required for Beta
- Ability to register environment conditions dynamically (like the heat)
## Planned for first release
- Write helpful README
- Set effects on player join
- Improve value structures of particle and skybox effects
- Make sounds adjust to changes by weather presets
- Ability to force set a wind speed via chat commands
## Nice to have
- Write documentation on how to add weathers and effects
@ -22,7 +18,6 @@
- Make switches between effects more smooth
- Adjust size of particle boxes based on player speed
- Create conditions for time of day, annual progression, biome filters
- Support for sail boats mod
## Future Plans & Ideas
- Complete season system

View File

@ -11,18 +11,11 @@ end
local function spawn_particles(player, particles)
local ppos = player:getpos()
local wind_x = climate_mod.state:get_float("wind_x")
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 wind = climate_api.environment.get_wind()
local amount = particles.amount * climate_mod.settings.particle_count
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({
x = wind.x,
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 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 vertical = math.abs(vector.normalize(vel).y) >= 0.6

View File

@ -2,6 +2,8 @@ if not climate_mod.settings.skybox then return end
local EFFECT_NAME = "climate_api:skybox"
local reset_data = {}
local function set_skybox(player, sky)
if not player.get_stars then return end
if sky.sky_data ~= nil then
@ -16,14 +18,14 @@ local function set_skybox(player, sky)
if sky.sun_data ~= nil then
player:set_sun(sky.sun_data)
end
if sky.stars_data ~= nil then
player:set_sun(sky.stars_data)
if sky.star_data ~= nil then
player:set_stars(sky.stars_data)
end
end
local function remove_skybox(player)
if not player.get_stars then return end
player:set_sky({ type = "regular", clouds = true})
player:set_sky({ type = "regular", clouds = true })
end
local function handle_effect(player_data)

View File

@ -31,7 +31,8 @@ climate_mod.settings = {
humidity = get_setting_number("humidity_base", 0),
time_spread = get_setting_number("time_spread", 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
@ -42,6 +43,7 @@ climate_mod.influences = {}
climate_mod.current_weather = {}
climate_mod.current_effects = {}
climate_mod.forced_weather = {}
climate_mod.forced_wind = nil
-- import core API
climate_mod.state = dofile(modpath .. "/lib/datastorage.lua")

View File

@ -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)

View File

@ -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 })

View File

@ -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)

View File

@ -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_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_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