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, diff --git a/locale/de.txt b/locale/de.txt index e652e49..193633a 100644 --- a/locale/de.txt +++ b/locale/de.txt @@ -51,6 +51,10 @@ Copy to craft grid: = Ins Fertigungsraster kopieren: All = Alles Alternate = Alternative Crafting Grid = Fertigungsraster +Show next recipe = Nächstes Rezept zeigen +Show next usage = Nächste Verwendung zeigen +Show previous recipe = Vorheriges Rezept zeigen +Show previous usage = Vorherige Verwendung zeigen Recipe %d of %d = Rezept %d von %d Usage %d of %d = Verwendung %d von %d No recipes = Keine Rezepte diff --git a/locale/template.txt b/locale/template.txt index e0e50f6..4e8e658 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -53,6 +53,10 @@ Copy to craft grid: = All = Alternate = Crafting Grid = +Show next recipe = +Show next usage = +Show previous recipe = +Show previous usage = Recipe %d of %d = Usage %d of %d = No recipes = diff --git a/register.lua b/register.lua index 978646b..66c9cef 100644 --- a/register.lua +++ b/register.lua @@ -207,6 +207,14 @@ local role_text = { recipe = "Result", usage = "Ingredient", } +local next_alt_text = { + recipe = "Show next recipe", + usage = "Show next usage", +} +local prev_alt_text = { + recipe = "Show previous recipe", + usage = "Show previous usage", +} local other_dir = { recipe = "usage", usage = "recipe", @@ -313,7 +321,10 @@ unified_inventory.register_page("craftguide", { if alternates and alternates > 1 then formspec = formspec.."label[5.5,"..(formspecy + 1.6)..";" ..string.format(F(recipe_text[dir]), alternate, alternates).."]" - .."button[5.5,"..(formspecy + 2)..";2,1;alternate;" .. F("Alternate") .. "]" + .."image_button[5.5,"..(formspecy + 2)..";1,1;ui_left_icon.png;alternate_prev;]" + .."image_button[6.5,"..(formspecy + 2)..";1,1;ui_right_icon.png;alternate;]" + .."tooltip[alternate_prev;"..F(prev_alt_text[dir]).."]" + .."tooltip[alternate;"..F(next_alt_text[dir]).."]" end return {formspec = formspec} end,