From 64a923f7fb92b18a2fb2e727a45c69df744559b8 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 3 Feb 2019 11:45:45 +0000 Subject: [PATCH] Fix sfinv not updating on creative grant/revoke --- mods/creative/init.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mods/creative/init.lua b/mods/creative/init.lua index ef190b8d..0f8d4dba 100644 --- a/mods/creative/init.lua +++ b/mods/creative/init.lua @@ -1,9 +1,24 @@ creative = {} +local function update_sfinv(name) + minetest.after(0, function() + local player = minetest.get_player_by_name(name) + if player then + if sfinv.get_page(player):sub(1, 9) == "creative:" then + sfinv.set_page(player, sfinv.get_homepage_name(player)) + else + sfinv.set_player_inventory_formspec(player) + end + end + end) +end + minetest.register_privilege("creative", { description = "Allow player to use creative inventory", give_to_singleplayer = false, - give_to_admin = false + give_to_admin = false, + on_grant = update_sfinv, + on_revoke = update_sfinv, }) local creative_mode_cache = minetest.settings:get_bool("creative_mode") -- 2.25.1