diff options
author | Alexander Weber <web.alexander@web.de> | 2018-02-14 02:19:15 +0100 |
---|---|---|
committer | sofar <sofar+github@foo-projects.org> | 2018-02-19 11:18:18 -0800 |
commit | 49620617524b626207fbf025474be6db4404e470 (patch) | |
tree | d4940de3e267b30cedbcb51bae47b1e42765b139 /unified_inventory_page.lua | |
parent | 4704e17dd2a833ebdd8e8f7081e11b05b6cdae4a (diff) |
moved the chat- and UI context to ram
Diffstat (limited to 'unified_inventory_page.lua')
-rw-r--r-- | unified_inventory_page.lua | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/unified_inventory_page.lua b/unified_inventory_page.lua index 91f4e57..ba7e917 100644 --- a/unified_inventory_page.lua +++ b/unified_inventory_page.lua @@ -15,12 +15,9 @@ unified_inventory.register_button("skins", { }) local function get_formspec(player) - -- unified inventory is stateless, but skins pager needs some context usage to be more flexible - local context = minetest.deserialize(player:get_attribute('skinsdb_unified_inventory_context')) or {} - context = skins.rebuild_formspec_context(player, context) + local context = skins.ui_context[player:get_player_name()] local formspec = "background[0.06,0.99;7.92,7.52;ui_misc_form.png]".. - skins.get_skin_selection_formspec(context, -0.2) - player:set_attribute('skinsdb_unified_inventory_context', minetest.serialize(context)) + skins.get_skin_selection_formspec(player, context, -0.2) return formspec end @@ -33,7 +30,6 @@ unified_inventory.register_page("skins_page", { -- click button handlers minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.skins then - player:set_attribute('skinsdb_unified_inventory_context',"") --reset context unified_inventory.set_inventory_formspec(player, "craft") return end @@ -42,23 +38,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return end - local context -- read context only if skins related action - for field, _ in pairs(fields) do - if field:sub(1,5) == "skins" then - context = minetest.deserialize(player:get_attribute('skinsdb_unified_inventory_context')) or {} - break - end - end - if not context then - return - end - + local context = skins.ui_context[player:get_player_name()] local action = skins.on_skin_selection_receive_fields(player, context, fields) if action == 'set' then - player:set_attribute('skinsdb_unified_inventory_context',"") --reset context unified_inventory.set_inventory_formspec(player, "skins") elseif action == 'page' then - player:set_attribute('skinsdb_unified_inventory_context', minetest.serialize(context)) unified_inventory.set_inventory_formspec(player, "skins_page") end end) |