From 1e7f06513429b2defe69ec6f9d8af1fb547b2500 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 3 Dec 2024 14:52:26 +0100 Subject: [PATCH 1/3] Fix `mcl_gamemode.get_gamemode` --- mods/PLAYER/mcl_gamemode/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/PLAYER/mcl_gamemode/init.lua b/mods/PLAYER/mcl_gamemode/init.lua index a43a9c1ff..bdce6ca74 100644 --- a/mods/PLAYER/mcl_gamemode/init.lua +++ b/mods/PLAYER/mcl_gamemode/init.lua @@ -44,7 +44,14 @@ function mcl_gamemode.get_gamemode(player) if mt_is_creative_enabled(player:get_player_name()) then return "creative" end - return player:get_meta():get_string("gamemode") + + local gm = player:get_meta():get_string("gamemode") + if gm == "" then + return "survival" + else + ---@diagnostic disable-next-line: return-type-mismatch + return gm + end end function minetest.is_creative_enabled(name) From bd1e50b00768cffc5c7df5e8b6b023d1df6e36b8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 3 Dec 2024 14:57:31 +0100 Subject: [PATCH 2/3] Save default value --- mods/PLAYER/mcl_gamemode/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/PLAYER/mcl_gamemode/init.lua b/mods/PLAYER/mcl_gamemode/init.lua index bdce6ca74..3f7b9cafa 100644 --- a/mods/PLAYER/mcl_gamemode/init.lua +++ b/mods/PLAYER/mcl_gamemode/init.lua @@ -47,6 +47,7 @@ function mcl_gamemode.get_gamemode(player) local gm = player:get_meta():get_string("gamemode") if gm == "" then + player:get_meta():set_string("gamemode", "survival") return "survival" else ---@diagnostic disable-next-line: return-type-mismatch From 8e908870f93f79333c45b1d1a29ed0b0487c8dae Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 3 Dec 2024 15:04:03 +0100 Subject: [PATCH 3/3] Use `get` instead of `get_string` --- mods/PLAYER/mcl_gamemode/init.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mods/PLAYER/mcl_gamemode/init.lua b/mods/PLAYER/mcl_gamemode/init.lua index 3f7b9cafa..2edc169f9 100644 --- a/mods/PLAYER/mcl_gamemode/init.lua +++ b/mods/PLAYER/mcl_gamemode/init.lua @@ -45,13 +45,13 @@ function mcl_gamemode.get_gamemode(player) return "creative" end - local gm = player:get_meta():get_string("gamemode") - if gm == "" then - player:get_meta():set_string("gamemode", "survival") - return "survival" - else + local gm = player:get_meta():get("gamemode") + if gm then ---@diagnostic disable-next-line: return-type-mismatch return gm + else + player:get_meta():set_string("gamemode", "survival") + return "survival" end end