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
texture = def.inventory_image
else
if not def.tiles then return texture end
local c = #def.tiles or 0 if def.inventory_image and #def.inventory_image > 0 then
local x = {} texture = def.inventory_image
for i, v in ipairs(def.tiles) do else
if type(v) == "table" then if not def.tiles then return texture end
x[i] = v.name local tiles = table.copy(def.tiles)
else
x[i] = v for k,v in pairs(tiles) do
end if type(v) == "table" then
i = i + 1 tiles[k] = v.name
end end
if not x[3] then x[3] = x[1] end end
if not x[4] then x[4] = x[3] end
texture = core.inventorycube(x[1], x[3], x[4]) -- 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
end end
return texture return texture
end end