|
45 | 45 | function drawers.get_inv_image(name)
|
46 | 46 | local texture = "blank.png"
|
47 | 47 | local def = core.registered_items[name]
|
48 |
| - if name ~= "air" and def then |
49 |
| - if def.inventory_image and #def.inventory_image > 0 then |
50 |
| - texture = def.inventory_image |
51 |
| - else |
52 |
| - if not def.tiles then return texture end |
53 |
| - |
54 |
| - local c = #def.tiles or 0 |
55 |
| - local x = {} |
56 |
| - for i, v in ipairs(def.tiles) do |
57 |
| - if type(v) == "table" then |
58 |
| - x[i] = v.name |
59 |
| - else |
60 |
| - x[i] = v |
61 |
| - end |
62 |
| - i = i + 1 |
| 48 | + if not def then return end |
| 49 | + |
| 50 | + if def.inventory_image and #def.inventory_image > 0 then |
| 51 | + texture = def.inventory_image |
| 52 | + else |
| 53 | + if not def.tiles then return texture end |
| 54 | + local tiles = table.copy(def.tiles) |
| 55 | + |
| 56 | + for k,v in pairs(tiles) do |
| 57 | + if type(v) == "table" then |
| 58 | + tiles[k] = v.name |
63 | 59 | end
|
64 |
| - if not x[3] then x[3] = x[1] end |
65 |
| - if not x[4] then x[4] = x[3] end |
66 |
| - texture = core.inventorycube(x[1], x[3], x[4]) |
| 60 | + end |
| 61 | + |
| 62 | + -- tiles: up, down, right, left, back, front |
| 63 | + -- inventorycube: up, front, right |
| 64 | + if #tiles <= 2 then |
| 65 | + texture = core.inventorycube(tiles[1], tiles[1], tiles[1]) |
| 66 | + elseif #tiles <= 5 then |
| 67 | + texture = core.inventorycube(tiles[1], tiles[3], tiles[3]) |
| 68 | + else -- full tileset |
| 69 | + texture = core.inventorycube(tiles[1], tiles[6], tiles[3]) |
67 | 70 | end
|
68 | 71 | end
|
| 72 | + |
69 | 73 | return texture
|
70 | 74 | end
|
71 | 75 |
|
|
0 commit comments