]> git.lizzy.rs Git - xdecor.git/commitdiff
Mailbox : enforce using 16px images in tablecolumn
authorJean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com>
Mon, 28 Mar 2016 11:39:09 +0000 (13:39 +0200)
committerJean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com>
Mon, 28 Mar 2016 11:55:00 +0000 (13:55 +0200)
mailbox.lua
textures/mailbox_blank16.png [new file with mode: 0644]

index a0f0528c428712b96a95e57c1f414af9a1fbb8e5..dbfd09e3375e2d2ed7fac10e517b1e43f8b65c00 100644 (file)
@@ -2,11 +2,13 @@ local mailbox = {}
 screwdriver = screwdriver or {}
 
 local function img_col(stack)
-       if not stack then return "" end
-       if stack.inventory_image ~= "" then
-               return stack.inventory_image:match("(.*)%.png")..".png"
+       local def = minetest.registered_items[stack]
+       if not def then return "" end
+
+       if def.inventory_image ~= "" then
+               return def.inventory_image:match("(.*)%.png")..".png"
        else
-               return stack.tiles[1]:match("(.*)%.png")..".png"
+               return def.tiles[1]:match("(.*)%.png")..".png"
        end
 end
 
@@ -23,7 +25,9 @@ function mailbox:formspec(pos, owner, num)
                                local stack_count = meta:get_string("stack"..i):match("%s(%d+)") or 1
 
                                giver = giver.."#FFFF00,"..giver_name..","..i..",#FFFFFF,x "..stack_count..","
-                               img = img..i.."="..img_col(minetest.registered_items[stack_name])..","
+                               -- Hack to force using a 16px resolution for images in formspec's tablecolumn.
+                               -- The engine doesn't scale them automatically yet.
+                               img = img..i.."=mailbox_blank16.png^"..img_col(stack_name)..","
                        end
                end
 
diff --git a/textures/mailbox_blank16.png b/textures/mailbox_blank16.png
new file mode 100644 (file)
index 0000000..849e622
Binary files /dev/null and b/textures/mailbox_blank16.png differ