From 6ceb56c3dc3b9e388723c76a34c863d0d72df127 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 20 Aug 2017 12:21:41 +0200 Subject: [PATCH] Disable worldedit_gui fallback code (closes #141) --- worldedit_gui/init.lua | 84 ++++-------------------------------------- 1 file changed, 8 insertions(+), 76 deletions(-) diff --git a/worldedit_gui/init.lua b/worldedit_gui/init.lua index d44d8bb..137a057 100644 --- a/worldedit_gui/init.lua +++ b/worldedit_gui/init.lua @@ -171,82 +171,14 @@ elseif rawget(_G, "sfinv") then --sfinv installed (part of minetest_game since 0 player:set_inventory_formspec(get_formspec(name, page)) end end -else --fallback button - -- FIXME: this is a huge clusterfuck and the back button is broken - local player_formspecs = {} - - local update_main_formspec = function(name) - local formspec = player_formspecs[name] - if not formspec then - return - end - local player = minetest.get_player_by_name(name) - if not player then --this is in case the player signs off while the media is loading - return - end - if (minetest.check_player_privs(name, {creative=true}) or - minetest.setting_getbool("creative_mode")) and - creative then --creative is active, add button to modified formspec - local creative_formspec = player:get_inventory_formspec() - local tab_id = tonumber(creative_formspec:match("tabheader%[.-;(%d+)%;")) - - if tab_id == 1 then - formspec = creative_formspec .. - "image_button[0,1;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" - elseif not tab_id then - formspec = creative_formspec .. - "image_button[6,0;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" - else - return - end - else - formspec = formspec .. "image_button[0,0;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" - end - player:set_inventory_formspec(formspec) - end - - minetest.register_on_joinplayer(function(player) - local name = player:get_player_name() - minetest.after(1, function() - if minetest.get_player_by_name(name) then --ensure the player is still signed in - player_formspecs[name] = player:get_inventory_formspec() - minetest.after(0.01, function() - update_main_formspec(name) - end) - end - end) - end) - - minetest.register_on_leaveplayer(function(player) - player_formspecs[player:get_player_name()] = nil - end) - - local gui_player_formspecs = {} - minetest.register_on_player_receive_fields(function(player, formname, fields) - local name = player:get_player_name() - if fields.worldedit_gui then --main page - gui_player_formspecs[name] = player:get_inventory_formspec() - worldedit.show_page(name, "worldedit_gui") - return true - elseif fields.worldedit_gui_exit then --return to original page - if gui_player_formspecs[name] then - player:set_inventory_formspec(gui_player_formspecs[name]) - end - return true - else --deal with creative_inventory setting the formspec on every single message - minetest.after(0.01,function() - update_main_formspec(name) - end) - return false --continue processing in creative inventory - end - end) - - worldedit.show_page = function(name, page) - local player = minetest.get_player_by_name(name) - if player then - player:set_inventory_formspec(get_formspec(name, page)) - end - end +else + error( + "worldedit_gui requires a supported \"gui management\" mod to be installed\n".. + "To use the GUI you need to either\n".. + "* Use minetest_game (at least 0.4.15) or a subgame with compatible sfinv\n".. + "* Install Unified Inventory or Inventory++\n".. + "If you do not want to use worldedit_gui, disable it by editing world.mt or from the Main Menu" + ) end worldedit.register_gui_function("worldedit_gui", {