From 9ec86aa2543aa97bac25282a5dae743fec587550 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Mon, 25 May 2020 17:23:38 +0200 Subject: [PATCH] bugfixing --- chatcommands.lua | 10 +++++++--- init.lua | 1 + integrations/day_night.lua | 4 ++-- integrations/epic_skybox.lua | 8 ++++---- integrations/epic_weather.lua | 4 ++-- integrations/no_clouds.lua | 4 ++-- transition.lua | 2 ++ 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/chatcommands.lua b/chatcommands.lua index a9e8c1d..e2029bb 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -11,7 +11,7 @@ minetest.register_chatcommand("area_effect_set", { params = " ", description = "Sets an area attribute", func = function(playername, param) - local _, _, id_str, key, value = string.find(param, "^([^%s]+)%s+([^%s])%s+(.*)$") + local _, _, id_str, key, value = string.find(param, "^([^%s]+)%s+([^%s]+)%s+(.*)$") if id_str == nil or not key then return true, "Invalid syntax!" end @@ -53,8 +53,12 @@ minetest.register_chatcommand("area_effect_get", { return true, "area-id is not numeric: " .. param end - local data = epic.data_area.get(id) - return true, "Area " .. id .. "\n" .. format_data(data) + local data = area_effects.get(id) + if not data then + return true, "No effects" + else + return true, "Area " .. id .. "\n" .. format_data(data) + end end }) diff --git a/init.lua b/init.lua index 55db398..998234b 100644 --- a/init.lua +++ b/init.lua @@ -16,6 +16,7 @@ dofile(MP.."/accessors.lua") dofile(MP.."/transition.lua") dofile(MP.."/hooks.lua") dofile(MP.."/log.lua") +dofile(MP.."/chatcommands.lua") if minetest.get_modpath("epic_skybox") then dofile(MP.."/integrations/epic_skybox.lua") diff --git a/integrations/day_night.lua b/integrations/day_night.lua index 56bb002..087999a 100644 --- a/integrations/day_night.lua +++ b/integrations/day_night.lua @@ -4,7 +4,7 @@ area_effects.register_effect("day_night", "float value from 0.0 to 1.0") area_effects.register_hook({ enter = function(player, id) local data = area_effects.get(id) - if data.day_night then + if data and data.day_night then local num = tonumber(data.day_night) player:override_day_night_ratio(num) end @@ -12,7 +12,7 @@ area_effects.register_hook({ leave = function(player, id) local data = area_effects.get(id) - if data.day_night then + if data and data.day_night then player:override_day_night_ratio(nil) end end diff --git a/integrations/epic_skybox.lua b/integrations/epic_skybox.lua index 3102b87..fbd6100 100644 --- a/integrations/epic_skybox.lua +++ b/integrations/epic_skybox.lua @@ -4,9 +4,9 @@ area_effects.register_effect("skybox", "names from /skybox_list") area_effects.register_hook({ enter = function(player, id) local data = area_effects.get(id) - if data.skybox then + if data and data.skybox then for _, skyboxdef in ipairs(epic_skybox.list) do - if skyboxdef == data.skybox then + if skyboxdef.name == data.skybox then epic_skybox.set_skybox(player, skyboxdef) break end @@ -16,8 +16,8 @@ area_effects.register_hook({ leave = function(player, id) local data = area_effects.get(id) - if data.skybox then - epic_skybox.set_skybox(player) + if data and data.skybox then + epic_skybox.set_skybox(player, {}) end end }) diff --git a/integrations/epic_weather.lua b/integrations/epic_weather.lua index a30be7e..5c650fd 100644 --- a/integrations/epic_weather.lua +++ b/integrations/epic_weather.lua @@ -4,14 +4,14 @@ area_effects.register_effect("weather", "weather definitions") area_effects.register_hook({ enter = function(player, id) local data = area_effects.get(id) - if data.weather then + if data and data.weather then epic_weather.current_weather[player:get_player_name()] = data.weather end end, leave = function(player, id) local data = area_effects.get(id) - if data.weather then + if data and data.weather then epic_weather.current_weather[player:get_player_name()] = nil end end diff --git a/integrations/no_clouds.lua b/integrations/no_clouds.lua index f29ccaf..1195ea7 100644 --- a/integrations/no_clouds.lua +++ b/integrations/no_clouds.lua @@ -4,14 +4,14 @@ area_effects.register_effect("no_clouds", "disables the clouds") area_effects.register_hook({ enter = function(player, id) local data = area_effects.get(id) - if data.no_clouds then + if data and data.no_clouds then player:set_clouds({density=0,speed=0}) end end, leave = function(player, id) local data = area_effects.get(id) - if data.no_clouds then + if data and data.no_clouds then player:set_clouds({ thickness=16, color={r=243, g=214, b=255, a=229}, diff --git a/transition.lua b/transition.lua index aafefc1..aaf43cb 100644 --- a/transition.lua +++ b/transition.lua @@ -32,6 +32,7 @@ local function check() if not active_entry[id] then -- player entered area_effects.run_hook("enter", { player, id }) + active_entry[id] = true end end @@ -40,6 +41,7 @@ local function check() if not current_ids[id] then -- player left area_effects.run_hook("leave", { player, id }) + active_entry[id] = nil end end end