diff --git a/ca_effects/damage.lua b/ca_effects/damage.lua index 4f3e14c..7b7d304 100644 --- a/ca_effects/damage.lua +++ b/ca_effects/damage.lua @@ -43,7 +43,7 @@ local function check_hit(player, ray) ) origin = vector.add(origin, windpos) end - local ray = minetest.raycast(origin, ppos) + ray = minetest.raycast(origin, ppos) local obj = ray:next() -- found nothing if obj == nil then return false end diff --git a/ca_effects/particles.lua b/ca_effects/particles.lua index 26c3766..6baab72 100644 --- a/ca_effects/particles.lua +++ b/ca_effects/particles.lua @@ -165,7 +165,7 @@ local function parse_config(player, particles) -- correct spawn coordinates to adjust for player movement 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.maxpos = vector.add(config.maxpos, velocity) end @@ -212,4 +212,4 @@ local function handle_effect(player_data) end climate_api.register_effect(EFFECT_NAME, handle_effect, "tick") -climate_api.set_effect_cycle(EFFECT_NAME, CYCLE_LENGTH) \ No newline at end of file +climate_api.set_effect_cycle(EFFECT_NAME, CYCLE_LENGTH) diff --git a/lib/api_utility.lua b/lib/api_utility.lua index 55adccc..ad72481 100644 --- a/lib/api_utility.lua +++ b/lib/api_utility.lua @@ -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 = {} function utility.rangelim(value, min, max) diff --git a/lib/main.lua b/lib/main.lua index 3c951e2..e6c6a1f 100644 --- a/lib/main.lua +++ b/lib/main.lua @@ -1,15 +1,6 @@ local GSCYCLE = 0.03 * 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 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 world_timer = 0 minetest.register_globalstep(function(dtime) @@ -29,7 +20,7 @@ minetest.register_globalstep(function(dtime) -- skip weather changes for offline players for effect, data in pairs(previous_effects) 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 end end @@ -47,4 +38,4 @@ minetest.register_globalstep(function(dtime) climate_mod.cycles[name].timer = climate_mod.cycles[name].timer + dtime end end -end) \ No newline at end of file +end) diff --git a/lib/soundloop.lua b/lib/soundloop.lua index 697bb40..b6a70f2 100644 --- a/lib/soundloop.lua +++ b/lib/soundloop.lua @@ -19,7 +19,6 @@ soundloop.play = function(player, sound, fade) if sounds[player] == nil then sounds[player] = {} end if sounds[player][sound.name] == nil then step = sound.gain / fade - start_gain = 0 elseif sounds[player][sound.name] ~= sound.gain then minetest.sound_stop(sounds[player][sound.name].handle) start_gain = sounds[player][sound.name].gain @@ -54,4 +53,4 @@ soundloop.stop = function(player, sound, fade) minetest.after(fade, minetest.sound_stop, handle) end -return soundloop \ No newline at end of file +return soundloop diff --git a/lib/trigger.lua b/lib/trigger.lua index c97695a..68959ef 100644 --- a/lib/trigger.lua +++ b/lib/trigger.lua @@ -68,7 +68,7 @@ local function is_weather_active(player, weather, env) end local function get_weather_effects(player, weather_config, env) - local config = {} + local config local effects = {} if type(weather_config.effects) == "function" then config = weather_config.effects(env) @@ -85,22 +85,19 @@ end function trigger.get_active_effects() local environments = {} + local effects = {} + climate_mod.current_weather = {} + for _, player in ipairs(minetest.get_connected_players()) do - local playername = player:get_player_name() + local pname = player:get_player_name() local hp = player:get_hp() -- skip weather presets for dead players if hp ~= nil and hp > 0 then - environments[playername] = trigger.get_player_environment(player) + environments[pname] = trigger.get_player_environment(player) end - end - - local effects = {} - climate_mod.current_weather = {} - 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 + local env = environments[pname] + if env ~= nil then + for wname, wconfig in pairs(climate_mod.weathers) do if is_weather_active(player, wname, env) then if climate_mod.current_weather[pname] == nil then climate_mod.current_weather[pname] = {} @@ -172,4 +169,4 @@ function trigger.call_handlers(name, effect, prev_effect) end end -return trigger \ No newline at end of file +return trigger