mirror of
https://github.com/minetest-mods/drawers.git
synced 2024-11-22 06:33:44 +01:00
Fix that LBM-restored visuals doesn't have a texture
This commit is contained in:
parent
95c378b10e
commit
a94a637f2a
15
init.lua
15
init.lua
@ -40,6 +40,8 @@ else
|
|||||||
CHEST_ITEMSTRING = "chest"
|
CHEST_ITEMSTRING = "chest"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local DEFAULT_VISUAL_TEXTURE = "drawers_empty.png"
|
||||||
|
|
||||||
drawers.node_box_simple = {
|
drawers.node_box_simple = {
|
||||||
{-0.5, -0.5, -0.4375, 0.5, 0.5, 0.5},
|
{-0.5, -0.5, -0.4375, 0.5, 0.5, 0.5},
|
||||||
{-0.5, -0.5, -0.5, -0.4375, 0.5, -0.4375},
|
{-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
|
end
|
||||||
|
|
||||||
local function get_inv_image(name)
|
local function get_inv_image(name)
|
||||||
local texture = default_texture
|
local texture = DEFAULT_VISUAL_TEXTURE
|
||||||
local def = minetest.registered_items[name]
|
local def = core.registered_items[name]
|
||||||
if name ~= "air" and def then
|
if name ~= "air" and def then
|
||||||
if def.inventory_image and #def.inventory_image > 0 then
|
if def.inventory_image and #def.inventory_image > 0 then
|
||||||
texture = def.inventory_image
|
texture = def.inventory_image
|
||||||
else
|
else
|
||||||
local c = #def.tiles
|
if not def.tiles then return texture end
|
||||||
|
|
||||||
|
local c = #def.tiles or 0
|
||||||
local x = {}
|
local x = {}
|
||||||
for i, v in ipairs(def.tiles) do
|
for i, v in ipairs(def.tiles) do
|
||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
@ -121,7 +125,7 @@ core.register_entity("drawers:visual", {
|
|||||||
self.texture = data.texture
|
self.texture = data.texture
|
||||||
else
|
else
|
||||||
self.drawer_pos = drawers.last_drawer_pos
|
self.drawer_pos = drawers.last_drawer_pos
|
||||||
self.texture = "drawers_empty.png"
|
self.texture = drawers.last_texture or DEFAULT_VISUAL_TEXTURE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -279,6 +283,7 @@ local function spawn_visual(pos)
|
|||||||
|
|
||||||
-- data for the new visual
|
-- data for the new visual
|
||||||
drawers.last_drawer_pos = pos
|
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 bdir = core.facedir_to_dir(node.param2)
|
||||||
local fdir = vector.new(-bdir.x, 0, -bdir.z)
|
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.x < 0 then obj:setyaw(0.5 * math.pi) end
|
||||||
if bdir.z < 0 then obj:setyaw(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
|
if bdir.x > 0 then obj:setyaw(1.5 * math.pi) end
|
||||||
|
|
||||||
|
drawers.last_texture = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- construct drawer
|
-- construct drawer
|
||||||
|
Loading…
Reference in New Issue
Block a user