diff options
author | Wuzzy <almikes@aol.com> | 2016-08-06 23:04:51 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-08-14 10:56:24 +0200 |
commit | a1e7b650ab2690f522dabf410149bd7e01425001 (patch) | |
tree | f35a2e58da9b0ed810b53b72085b9386aa55f878 /callbacks.lua | |
parent | 23a27b38ae7b33588b1d12ad954fe3f62d2b4e14 (diff) |
Guide: Allow to move back and forth in alternates
Diffstat (limited to 'callbacks.lua')
-rw-r--r-- | callbacks.lua | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/callbacks.lua b/callbacks.lua index 9387154..e86cac6 100644 --- a/callbacks.lua +++ b/callbacks.lua @@ -160,8 +160,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) {to_player=player_name, gain = 1.0}) end - -- alternate button - if not fields.alternate then + -- alternate buttons + if not (fields.alternate or fields.alternate_prev) then return end minetest.sound_play("click", @@ -178,9 +178,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if alternates <= 1 then return end - local alternate = unified_inventory.alternate[player_name] + 1 - if alternate > alternates then - alternate = 1 + local alternate + if fields.alternate then + alternate = unified_inventory.alternate[player_name] + 1 + if alternate > alternates then + alternate = 1 + end + elseif fields.alternate_prev then + alternate = unified_inventory.alternate[player_name] - 1 + if alternate < 1 then + alternate = alternates + end end unified_inventory.alternate[player_name] = alternate unified_inventory.set_inventory_formspec(player, |