From fb13dfec4f4902f691abb92f267a3f9bb6c3688f Mon Sep 17 00:00:00 2001 From: Michieal Date: Fri, 8 Dec 2023 21:00:11 -0500 Subject: [PATCH] Reworked some of the Apply_Modifier code to help prevent errors. --- mods/PLAYER/mcl_fovapi/init.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mods/PLAYER/mcl_fovapi/init.lua b/mods/PLAYER/mcl_fovapi/init.lua index de3dfa01a..debe1142e 100644 --- a/mods/PLAYER/mcl_fovapi/init.lua +++ b/mods/PLAYER/mcl_fovapi/init.lua @@ -74,18 +74,23 @@ function mcl_fovapi.apply_modifier(player, modifier_name) if mcl_fovapi.registered_modifiers[modifier_name] == nil then return end - if mcl_fovapi.applied_modifiers ~= nil and mcl_fovapi.applied_modifiers[player] ~= nil and mcl_fovapi.applied_modifiers[player][modifier_name] ~= nil then + if mcl_fovapi.applied_modifiers and mcl_fovapi.applied_modifiers[player] and mcl_fovapi.applied_modifiers[player][modifier_name] then if mcl_fovapi.applied_modifiers[player][modifier_name] and mcl_fovapi.applied_modifiers[player][modifier_name] == true then return end end + if mcl_fovapi.applied_modifiers[player] == nil then + mcl_fovapi.applied_modifiers[player] = {} + end + local modifier = mcl_fovapi.registered_modifiers[modifier_name] if modifier.on_start ~= nil then modifier.on_start(player) end mcl_fovapi.applied_modifiers[player][modifier_name] = true -- set the applied to be true. + if DEBUG then minetest.log("FOV::Player Applied Modifiers :" .. dump(mcl_fovapi.applied_modifiers[player])) end