From a1ca455d6f21875cfdb9714e5d8a7e3be2c67792 Mon Sep 17 00:00:00 2001 From: Thomas--S Date: Mon, 31 Oct 2016 19:34:29 +0100 Subject: [PATCH] Only show page-related stuff when there are more than one pages. Suggested by @Wuzzy2 Additionally, add a clear selection button. --- init.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index a118e6b..ec65620 100755 --- a/init.lua +++ b/init.lua @@ -387,9 +387,13 @@ function ts_doors.workshop.update_formspec(pos) end end end - fs = fs .. "button[6,2.25;1,1;prevpage;<-]" - fs = fs .. "button[6,3.25;1,1;nextpage;->]" - fs = fs .. "label[6,4;" .. string.format("Page %s of %s", page, maxpage) .. "]" + fs = fs .. "button[6, 1;1,1;noselection;X]" + fs = fs .. "tooltip[noselection;Remove Current Selection]" + if maxpage > 1 then + fs = fs .. "button[6,2.25;1,1;prevpage;<-]" + fs = fs .. "button[6,3.25;1,1;nextpage;->]" + fs = fs .. "label[6,4;" .. string.format("Page %s of %s", page, maxpage) .. "]" + end fs = fs .. "label[7.5,0.2;Current]" fs = fs .. "label[7.5,0.5;Door]" fs = fs .. "item_image[7.5,1;1,1;" .. selection .. "]" @@ -520,6 +524,8 @@ local function on_receive_fields(pos, formname, fields, sender) meta:set_int("page", meta:get_int("page") - 1) elseif fields.nextpage then meta:set_int("page", meta:get_int("page") + 1) + elseif fields.noselection then + meta:set_string("selection", "") else for item, recipe in pairs(ts_doors.registered_doors) do if fields[get_door_name(meta, item)] then