summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--API.md5
-rw-r--r--init.lua6
2 files changed, 9 insertions, 2 deletions
diff --git a/API.md b/API.md
index 471800b..2cc8711 100644
--- a/API.md
+++ b/API.md
@@ -492,7 +492,10 @@ adding more galleries is not supported and will lead to bugs.
### Parameters
* `imagedata`: List of images to be displayed in the specified order. All images must
have the same aspect ratio. It's a table of tables with this format:
- * `image`: Texture name of an image
+ * `imagetype`: Type of image to be used (optional):
+ * `"image"`: Texture file (default)
+ * `"item"`: Item image, specified as itemstring
+ * `image`: What to display. Depending on `imagetype`, a texture file or itemstring
* `playername`: Name of the player who is viewing the entry in question
* `x`: Formspec X coordinate of the top left corner (optional)
* `y`: Formspec Y coordinate of the top left corner (optional)
diff --git a/init.lua b/init.lua
index 04fda87..8de2874 100644
--- a/init.lua
+++ b/init.lua
@@ -609,7 +609,11 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width,
local xoffset = buttonoffset + (x + pos * iw)
local nx = xoffset - 0.2
local ny = y - 0.05
- formstring = formstring .. "image["..xoffset..","..y..";"..iw..","..ih..";"..imagedata[i].image.."]"
+ if imagedata[i].imagetype == "item" then
+ formstring = formstring .. "item_image["..xoffset..","..y..";"..iw..","..ih..";"..imagedata[i].image.."]"
+ else
+ formstring = formstring .. "image["..xoffset..","..y..";"..iw..","..ih..";"..imagedata[i].image.."]"
+ end
formstring = formstring .. "label["..nx..","..ny..";"..i.."]"
pos = pos + 1
end