summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-11-29 16:40:41 +0100
committerWuzzy <almikes@aol.com>2016-11-29 16:41:54 +0100
commit330e83323c7c4d9b2084772790ab89227ce93a57 (patch)
treeb77cbdb24e8250b95af35adf0e4d19cde4078656
parentfa73638eb715a236e7587d2ca95c25bdd1ee4c39 (diff)
Force maximum gallery index
-rw-r--r--init.lua7
1 files changed, 7 insertions, 0 deletions
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