summaryrefslogtreecommitdiff
path: root/lua/helpers.lua
diff options
context:
space:
mode:
authorLNJ <git@lnj.li>2017-04-14 18:59:42 +0200
committerLNJ <git@lnj.li>2017-04-14 18:59:42 +0200
commit4260e1fc896e2a255d470c5de16da9e8f36f5d75 (patch)
tree4b78cdfeab4c29c2f5203295c4e2744317cd3536 /lua/helpers.lua
parentbb9bbe2ff460110bdf71a46ae74bdfd5edd5d354 (diff)
Fix inventory cubes; using fitting tiles now
Diffstat (limited to 'lua/helpers.lua')
-rwxr-xr-xlua/helpers.lua40
1 files changed, 22 insertions, 18 deletions
diff --git a/lua/helpers.lua b/lua/helpers.lua
index af5207c..89785a8 100755
--- a/lua/helpers.lua
+++ b/lua/helpers.lua
@@ -45,27 +45,31 @@ end
function drawers.get_inv_image(name)
local texture = "blank.png"
local def = core.registered_items[name]
- if name ~= "air" and def then
- 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
- local x = {}
- for i, v in ipairs(def.tiles) do
- if type(v) == "table" then
- x[i] = v.name
- else
- x[i] = v
- end
- i = i + 1
+ 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 tiles = table.copy(def.tiles)
+
+ for k,v in pairs(tiles) do
+ if type(v) == "table" then
+ tiles[k] = v.name
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
+
+ -- 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
end