Mailbox : enforce using 16px images in tablecolumn

This commit is contained in:
Jean-Patrick Guerrero 2016-03-28 13:39:09 +02:00
parent 114cef1534
commit a64dbfca47
2 changed files with 9 additions and 5 deletions

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B