From df6f2eb80a2c4bfb9700924bde34b06182484788 Mon Sep 17 00:00:00 2001 From: mckayshirou Date: Thu, 13 Jul 2023 22:25:19 -0400 Subject: [PATCH] fix creative mode mod backguard compatibility for all engines * dont follow the creative upstream mod, its just wrapper around get_bool(creative) setting, so create a check privilegie function and provide backguard compatibility checks * backported fix from https://codeberg.org/minenux/minetest-game-subnasa/commit/c770d5cb4345a1a7454522e5cb0b5b483b91ab53 same backported from https://notabug.org/minenux/minetest-game-subnasa/commit/c770d5cb4345a1a7454522e5cb0b5b483b91ab53 --- init.lua | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/init.lua b/init.lua index 29f3923..75ddef0 100644 --- a/init.lua +++ b/init.lua @@ -68,28 +68,24 @@ minetest.register_privilege("creative", privs_definition) local creative_mode_cache = minetest.settings:get_bool("creative_mode") --- backguard compatibility -function creative.is_creative(name) - if creative.is_53 then - if name == "" then - return minetest.is_creative_enabled(name) - else - return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache - end +function minetest.is_creative_enabled(name) + if name == "" then + return creative_mode_cache else return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache end end --- Override the engine's creative mode function -local old_is_creative_enabled = creative.is_creative -function minetest.is_creative_enabled(name) +-- backguard compatibility +function creative.is_creative(name) if name == "" then - return old_is_creative_enabled(name) + return creative_mode_cache + else + return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache end - return minetest.check_player_privs(name, {creative = true}) or old_is_creative_enabled(name) end + -- For backwards compatibility: function creative.is_enabled_for(name) return creative.is_creative(name)