mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-12-26 02:30:40 +01:00
Make sfinv gui code compatible with sfinv as included in MTG 0.4.15
fixes #142
This commit is contained in:
parent
acc9188828
commit
1fabe60d77
@ -145,13 +145,21 @@ elseif rawget(_G, "sfinv") then --sfinv installed (part of minetest_game since 0
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
--compatibility with pre-0.4.16 sfinv
|
||||||
|
local set_page = sfinv.set_page or function(player, name)
|
||||||
|
--assumptions: src pg has no leave callback, dst pg has no enter callback
|
||||||
|
local ctx = {page=name}
|
||||||
|
sfinv.contexts[player:get_player_name()] = ctx
|
||||||
|
sfinv.set_player_inventory_formspec(player, ctx)
|
||||||
|
end
|
||||||
|
|
||||||
--show the form when the button is pressed and hide it when done
|
--show the form when the button is pressed and hide it when done
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if fields.worldedit_gui then --main page
|
if fields.worldedit_gui then --main page
|
||||||
worldedit.show_page(player:get_player_name(), "worldedit_gui")
|
worldedit.show_page(player:get_player_name(), "worldedit_gui")
|
||||||
return true
|
return true
|
||||||
elseif fields.worldedit_gui_exit then --return to original page
|
elseif fields.worldedit_gui_exit then --return to original page
|
||||||
sfinv.set_page(player, "sfinv:crafting")
|
set_page(player, "sfinv:crafting")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user