]> git.lizzy.rs Git - xdecor.git/commitdiff
Fix mailbox error (#52)
authorRui <Rui914@users.noreply.github.com>
Tue, 31 May 2016 14:37:32 +0000 (23:37 +0900)
committerAuke Kok <sofar+github@foo-projects.org>
Tue, 31 May 2016 14:37:32 +0000 (07:37 -0700)
`tiles` is not a required field. Indexing it may fail.

Fix #51

mailbox.lua

index 1985eea888c06fbaaa2f87a44c35a90a35d9a862..f538ab61336b72856d61db0f21a009cf5e9b7a46 100644 (file)
@@ -8,7 +8,12 @@ local function img_col(stack)
        if def.inventory_image ~= "" then
                return def.inventory_image:match("(.*)%.png")..".png"
        end
-       return def.tiles[1]:match("(.*)%.png")..".png"
+
+       if def.tiles and def.tiles[1] then
+               return def.tiles[1]:match("(.*)%.png")..".png"
+       end
+
+       return ""
 end
 
 function mailbox:formspec(pos, owner, num)