Fix crash with certain mods enabled (address #40)

This commit is contained in:
Jean-Patrick Guerrero 2021-12-14 21:51:02 +01:00
parent c9f7e0a40e
commit 7275767427

View File

@ -1,3 +1,4 @@
local PNG = i3.files.styles()
local replacements = {fuel = {}} local replacements = {fuel = {}}
local http = ... local http = ...
@ -285,29 +286,25 @@ end
local function get_cube(tiles) local function get_cube(tiles)
if not true_table(tiles) then if not true_table(tiles) then
return "i3_blank.png" return PNG.blank
end end
local t = copy(tiles) local top = tiles[1] or PNG.blank
local texture if is_table(top) then
top = top.name or top.image
for k, v in pairs(t) do
if type(v) == "table" then
t[k] = v.name
end
end end
-- Tiles: up, down, right, left, back, front local left = tiles[3] or top or PNG.blank
-- Inventory cube: up, front, right if is_table(left) then
if #t <= 2 then left = left.name or left.image
texture = draw_cube(t[1], t[1], t[1])
elseif #t <= 5 then
texture = draw_cube(t[1], t[3], t[3])
else -- Full tileset
texture = draw_cube(t[1], t[6], t[3])
end end
return texture local right = tiles[5] or left or PNG.blank
if is_table(right) then
right = right.name or right.image
end
return draw_cube(top, left, right)
end end
local function init_cubes() local function init_cubes()