Fix inventory cubes; using fitting tiles now

This commit is contained in:
LNJ 2017-04-14 18:59:42 +02:00
parent bb9bbe2ff4
commit 4260e1fc89
No known key found for this signature in database
GPG Key ID: 69268DBD835B6B0B

@ -45,27 +45,31 @@ end
function drawers.get_inv_image(name) function drawers.get_inv_image(name)
local texture = "blank.png" local texture = "blank.png"
local def = core.registered_items[name] local def = core.registered_items[name]
if name ~= "air" and def then if not def then return end
if def.inventory_image and #def.inventory_image > 0 then if def.inventory_image and #def.inventory_image > 0 then
texture = def.inventory_image texture = def.inventory_image
else else
if not def.tiles then return texture end if not def.tiles then return texture end
local tiles = table.copy(def.tiles)
local c = #def.tiles or 0 for k,v in pairs(tiles) do
local x = {}
for i, v in ipairs(def.tiles) do
if type(v) == "table" then if type(v) == "table" then
x[i] = v.name tiles[k] = v.name
else
x[i] = v
end
i = i + 1
end
if not x[3] then x[3] = x[1] end
if not x[4] then x[4] = x[3] end
texture = core.inventorycube(x[1], x[3], x[4])
end end
end end
-- tiles: up, down, right, left, back, front
-- inventorycube: up, front, right
if #tiles <= 2 then
texture = core.inventorycube(tiles[1], tiles[1], tiles[1])
elseif #tiles <= 5 then
texture = core.inventorycube(tiles[1], tiles[3], tiles[3])
else -- full tileset
texture = core.inventorycube(tiles[1], tiles[6], tiles[3])
end
end
return texture return texture
end end