Skip to content

Commit

Permalink
Mailbox: Fix animation texture error (minetest-mods#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui authored and sofar committed Jun 6, 2016
1 parent e9f6e60 commit 5248785
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions mailbox.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
local mailbox = {}
screwdriver = screwdriver or {}

local function get_img(img)
local img_name = img:match("(.*)%.png")
if img_name then return img_name..".png" end
end

local function img_col(stack)
local def = minetest.registered_items[stack]
if not def then return "" end

if def.inventory_image ~= "" then
return def.inventory_image:match("(.*)%.png")..".png"
local img = get_img(def.inventory_image)
if img then return img end
end

if def.tiles and def.tiles[1] then
return def.tiles[1]:match("(.*)%.png")..".png"
if def.tiles then
local img
local tile = def.tiles[1]

if type(tile) == "table" then
img = get_img(tile.name)
elseif type(tile) == "string" then
img = get_img(tile)
end

if img then return img end
end

return ""
Expand Down Expand Up @@ -136,4 +151,3 @@ xdecor.register("mailbox", {
allow_metadata_inventory_put = mailbox.put,
after_place_node = mailbox.after_place_node
})

0 comments on commit 5248785

Please sign in to comment.