diff options
author | LNJ <git@lnj.li> | 2017-03-28 21:48:37 +0200 |
---|---|---|
committer | LNJ <git@lnj.li> | 2017-03-28 21:48:37 +0200 |
commit | a94a637f2a7d7786c975f66efa57b8fb866ecd18 (patch) | |
tree | a61b915e4d812b298b127e7701d2e6b66c3b4550 /init.lua | |
parent | 95c378b10e02e98022913460cc47c02708dcce34 (diff) |
Fix that LBM-restored visuals doesn't have a texture
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -40,6 +40,8 @@ else CHEST_ITEMSTRING = "chest" end +local DEFAULT_VISUAL_TEXTURE = "drawers_empty.png" + drawers.node_box_simple = { {-0.5, -0.5, -0.4375, 0.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, -0.4375, 0.5, -0.4375}, @@ -62,13 +64,15 @@ local function gen_info_text(basename, count, factor, stack_max) end local function get_inv_image(name) - local texture = default_texture - local def = minetest.registered_items[name] + local texture = DEFAULT_VISUAL_TEXTURE + 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 - local c = #def.tiles + 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 @@ -121,7 +125,7 @@ core.register_entity("drawers:visual", { self.texture = data.texture else self.drawer_pos = drawers.last_drawer_pos - self.texture = "drawers_empty.png" + self.texture = drawers.last_texture or DEFAULT_VISUAL_TEXTURE end @@ -279,6 +283,7 @@ local function spawn_visual(pos) -- data for the new visual drawers.last_drawer_pos = pos + drawers.last_texture = get_inv_image(core.get_meta(pos):get_string("name")) local bdir = core.facedir_to_dir(node.param2) local fdir = vector.new(-bdir.x, 0, -bdir.z) @@ -289,6 +294,8 @@ local function spawn_visual(pos) if bdir.x < 0 then obj:setyaw(0.5 * math.pi) end if bdir.z < 0 then obj:setyaw(math.pi) end if bdir.x > 0 then obj:setyaw(1.5 * math.pi) end + + drawers.last_texture = nil end -- construct drawer |