summaryrefslogtreecommitdiff
path: root/unified_inventory_page.lua
diff options
context:
space:
mode:
authorAlexander Weber <web.alexander@web.de>2017-07-24 17:56:09 +0200
committerAlexander Weber <web.alexander@web.de>2017-07-24 17:56:09 +0200
commit7791ac7fdff2e6179948fc62001ca8b0ebd8ca7f (patch)
tree8623f51de59a5c57ca785b609e4bf3ca21f2d17f /unified_inventory_page.lua
parente2e2927fe87b0da2844c29d266b62aea6a2d48c4 (diff)
hide paging if 1 page only
Diffstat (limited to 'unified_inventory_page.lua')
-rw-r--r--unified_inventory_page.lua40
1 files changed, 21 insertions, 19 deletions
diff --git a/unified_inventory_page.lua b/unified_inventory_page.lua
index 0bbb854..58e8ae6 100644
--- a/unified_inventory_page.lua
+++ b/unified_inventory_page.lua
@@ -71,26 +71,28 @@ for page=1, total_pages do
skin:get_preview()..";skins_set$"..i..";]"..
"tooltip[skins_set$"..i..";"..minetest.formspec_escape(skin:get_meta_string("name")).."]")
end
- local page_prev = page - 1
- local page_next = page + 1
- if page_prev < 1 then
- page_prev = total_pages
- end
- if page_next > total_pages then
- page_next = 1
- end
- local page_list = ""
- dropdown_values = {}
- for pg=1, total_pages do
- local pagename = S("Page").." "..pg.."/"..total_pages
- dropdown_values[pagename] = pg
- if pg > 1 then page_list = page_list.."," end
- page_list = page_list..pagename
+ if total_pages > 1 then
+ local page_prev = page - 1
+ local page_next = page + 1
+ if page_prev < 1 then
+ page_prev = total_pages
+ end
+ if page_next > total_pages then
+ page_next = 1
+ end
+ local page_list = ""
+ dropdown_values = {}
+ for pg=1, total_pages do
+ local pagename = S("Page").." "..pg.."/"..total_pages
+ dropdown_values[pagename] = pg
+ if pg > 1 then page_list = page_list.."," end
+ page_list = page_list..pagename
+ end
+ formspec = (formspec
+ .."button[0,3.8;1,.5;skins_page$"..page_prev..";<<]"
+ .."dropdown[1,3.68;6.5,.5;skins_selpg;"..page_list..";"..page.."]"
+ .."button[7,3.8;1,.5;skins_page$"..page_next..";>>]")
end
- formspec = (formspec
- .."button[0,3.8;1,.5;skins_page$"..page_prev..";<<]"
- .."dropdown[1,3.68;6.5,.5;skins_selpg;"..page_list..";"..page.."]"
- .."button[7,3.8;1,.5;skins_page$"..page_next..";>>]")
unified_inventory.register_page("skins_page$"..(page), {
get_formspec = function(player)
return {formspec=formspec}