From 330e83323c7c4d9b2084772790ab89227ce93a57 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 29 Nov 2016 16:40:41 +0100 Subject: Force maximum gallery index --- init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/init.lua b/init.lua index 45dff2a..9d724e6 100644 --- a/init.lua +++ b/init.lua @@ -523,6 +523,7 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, if rows == nil then rows = 3 end local imageindex = doc.data.players[playername].galidx + doc.data.players[playername].maxgalidx = #imagedata if aspect_ratio == nil then aspect_ratio = (2/3) end local pos = 0 @@ -1057,6 +1058,10 @@ function doc.process_form(player,formname,fields) elseif fields["doc_button_gallery_next"] then local cid, eid = doc.get_selection(playername) doc.data.players[playername].galidx = doc.data.players[playername].galidx + 1 + if doc.data.players[playername].galidx > doc.data.players[playername].maxgalidx then + doc.data.players[playername].galidx = doc.data.players[playername].maxgalidx + end + local formspec = doc.formspec_core(3)..doc.formspec_entry(cid, eid, playername) minetest.show_formspec(playername, "doc:entry", formspec) end @@ -1084,6 +1089,8 @@ minetest.register_on_joinplayer(function(player) playerdata = doc.data.players[playername] -- Gallery index, stores current index of first displayed image in a gallery playerdata.galidx = 1 + -- Maximum gallery index (index of last image in gallery) + playerdata.maxgalidx = 1 -- Table for persistant data playerdata.stored_data = {} -- Contains viewed entries -- cgit v1.2.3