diff --git a/ROADMAP.md b/ROADMAP.md index d85c423..b645b9e 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -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 diff --git a/ca_effects/particles.lua b/ca_effects/particles.lua index 0ef47c7..6375cb8 100644 --- a/ca_effects/particles.lua +++ b/ca_effects/particles.lua @@ -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 diff --git a/ca_effects/skybox.lua b/ca_effects/skybox.lua index 6c529da..09f52df 100644 --- a/ca_effects/skybox.lua +++ b/ca_effects/skybox.lua @@ -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) diff --git a/init.lua b/init.lua index 8376730..a7e6f81 100644 --- a/init.lua +++ b/init.lua @@ -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") diff --git a/lib/commands.lua b/lib/commands.lua index 7e71530..9a92d2b 100644 --- a/lib/commands.lua +++ b/lib/commands.lua @@ -77,6 +77,32 @@ minetest.register_chatcommand("set_humidity", { end }) +minetest.register_chatcommand("set_wind", { + params = "", + 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) diff --git a/lib/environment.lua b/lib/environment.lua index 6fb92c6..3a8d2ee 100644 --- a/lib/environment.lua +++ b/lib/environment.lua @@ -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 }) diff --git a/lib/influences.lua b/lib/influences.lua index 6e3ebfc..87a3a6b 100644 --- a/lib/influences.lua +++ b/lib/influences.lua @@ -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) diff --git a/settingtypes.txt b/settingtypes.txt index 7dfd942..2ec012a 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file