diff options
author | sfan5 <sfan5@live.de> | 2017-08-20 12:13:56 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2017-08-20 12:13:56 +0200 |
commit | 1fabe60d77e103f88eb4a8ae31c7fcf526248294 (patch) | |
tree | 2eebbb149f5c8bc6a4ad1fe4d9e2b8f4e9b5d950 | |
parent | acc91888280c8f6fb3631ae10634edd0df403e73 (diff) |
Make sfinv gui code compatible with sfinv as included in MTG 0.4.15
fixes #142
-rw-r--r-- | worldedit_gui/init.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/worldedit_gui/init.lua b/worldedit_gui/init.lua index dafd7c2..d44d8bb 100644 --- a/worldedit_gui/init.lua +++ b/worldedit_gui/init.lua @@ -145,13 +145,21 @@ elseif rawget(_G, "sfinv") then --sfinv installed (part of minetest_game since 0 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 minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.worldedit_gui then --main page worldedit.show_page(player:get_player_name(), "worldedit_gui") return true elseif fields.worldedit_gui_exit then --return to original page - sfinv.set_page(player, "sfinv:crafting") + set_page(player, "sfinv:crafting") return true end return false |