mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-12-25 10:10:41 +01:00
Disable worldedit_gui fallback code (closes #141)
This commit is contained in:
parent
1fabe60d77
commit
6ceb56c3dc
@ -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))
|
player:set_inventory_formspec(get_formspec(name, page))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else --fallback button
|
else
|
||||||
-- FIXME: this is a huge clusterfuck and the back button is broken
|
error(
|
||||||
local player_formspecs = {}
|
"worldedit_gui requires a supported \"gui management\" mod to be installed\n"..
|
||||||
|
"To use the GUI you need to either\n"..
|
||||||
local update_main_formspec = function(name)
|
"* Use minetest_game (at least 0.4.15) or a subgame with compatible sfinv\n"..
|
||||||
local formspec = player_formspecs[name]
|
"* Install Unified Inventory or Inventory++\n"..
|
||||||
if not formspec then
|
"If you do not want to use worldedit_gui, disable it by editing world.mt or from the Main Menu"
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
worldedit.register_gui_function("worldedit_gui", {
|
worldedit.register_gui_function("worldedit_gui", {
|
||||||
|
Loading…
Reference in New Issue
Block a user