Fix texturing of wall torches

This commit is contained in:
Wuzzy 2019-08-31 12:27:33 +02:00
parent b890ac42d5
commit d18cc27c96
5 changed files with 163 additions and 153 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -2,23 +2,25 @@ local S = minetest.get_translator("default")
-- Torches -- Torches
minetest.register_node(
"default:torch_dead",
local function register_torch(subname, description, tiles, overlay_tiles, overlay_side_R90, inv_image, light)
minetest.register_node(
"default:"..subname,
{ {
description = S("Dead Torch"), description = description,
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = tiles,
"default_torch_ends.png", overlay_tiles = overlay_tiles,
"default_torch_ends.png", inventory_image = inv_image,
"default_torch_base.png", wield_image = inv_image,
},
inventory_image = "default_torch_dead_inventory.png",
wield_image = "default_torch_dead_inventory.png",
paramtype = "light", paramtype = "light",
paramtype2 = "wallmounted", paramtype2 = "wallmounted",
light_source = light,
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
floodable = true, floodable = true,
node_placement_prediction = "",
node_box = { node_box = {
type = "wallmounted", type = "wallmounted",
wall_top = {-2/16, 0, -2/16, 2/16, 0.5, 2/16}, wall_top = {-2/16, 0, -2/16, 2/16, 0.5, 2/16},
@ -28,25 +30,91 @@ minetest.register_node(
groups = {choppy = 2, dig_immediate = 3, attached_node = 1}, groups = {choppy = 2, dig_immediate = 3, attached_node = 1},
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) on_construct = function(pos)
local node = minetest.get_node(pos)
minetest.register_node( local dir = minetest.wallmounted_to_dir(node.param2)
"default:torch_weak", if dir.x ~= 0 or dir.z ~= 0 then
minetest.set_node(pos, {name="default:"..subname.."_wall", param2 = node.param2})
end
end,
})
local copy, copy_o
for i=1,6 do
if tiles[i] ~= nil then
copy = tiles[i]
else
tiles[i] = copy
end
if overlay_tiles then
if overlay_tiles[i] ~= nil then
copy_o = overlay_tiles[i]
else
overlay_tiles[i] = copy_o
end
end
end
local copy_tile = function(tile)
if type(tile) == "table" then
return table.copy(tile)
else
return tile
end
end
local overlay_tiles2
if overlay_tiles then
overlay_tiles2 = {
copy_tile(overlay_tiles[3]),
copy_tile(overlay_tiles[4]),
overlay_side_R90,
overlay_side_R90,
copy_tile(overlay_tiles[1]),
copy_tile(overlay_tiles[2]),
}
end
local tiles2
if tiles then
tiles2 = {
tiles[3],
tiles[4],
tiles[5].."^[transformR90",
tiles[6].."^[transformR90",
tiles[1],
tiles[2],
}
end
minetest.register_node(
"default:"..subname.."_wall",
{ {
description = S("Weak Torch"),
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = tiles2,
{ overlay_tiles = overlay_tiles2,
name = "default_torch_ends.png", inventory_image = inv_image,
wield_image = inv_image,
paramtype = "light",
paramtype2 = "wallmounted",
light_source = light,
sunlight_propagates = true,
walkable = false,
floodable = true,
node_box = {
type = "wallmounted",
wall_top = {-2/16, 0, -2/16, 2/16, 0.5, 2/16},
wall_bottom = {-2/16, -0.5, -2/16, 2/16, 0, 2/16},
wall_side = {-0.5, -8/16, -2/16, -0.5+4/16, 0, 2/16},
}, },
{ drop = "default:"..subname,
name = "default_torch_ends.png", groups = {choppy = 2, dig_immediate = 3, attached_node = 1, not_in_creative_inventory = 1},
}, is_ground_content = false,
{ sounds = default.node_sound_defaults(),
name = "default_torch_base.png", })
},
},
overlay_tiles = {
end
local tiles_base = {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}
local overlay_tiles_weak = {
{ {
name = "default_torch_weak_ends_overlay.png", name = "default_torch_weak_ends_overlay.png",
animation = { animation = {
@ -57,13 +125,7 @@ minetest.register_node(
}, },
}, },
{ {
name = "default_torch_weak_ends_overlay.png", name = "blank.png"
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.0,
},
}, },
{ {
name = "default_torch_weak_overlay.png", name = "default_torch_weak_overlay.png",
@ -74,43 +136,8 @@ minetest.register_node(
length = 1.0, length = 1.0,
}, },
}, },
}, }
inventory_image = "default_torch_weak_inventory.png", local overlay_tiles_normal = {
wield_image = "default_torch_weak_inventory.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
floodable = true,
light_source = default.LIGHT_MAX-4,
node_box = {
type = "wallmounted",
wall_top = {-2/16, 0, -2/16, 2/16, 0.5, 2/16},
wall_bottom = {-2/16, -0.5, -2/16, 2/16, 0, 2/16},
wall_side = {-0.5, -8/16, -2/16, -0.5+4/16, 0, 2/16},
},
groups = {choppy = 2, dig_immediate = 3, attached_node = 1},
is_ground_content = false,
sounds = default.node_sound_defaults(),
})
minetest.register_node(
"default:torch",
{
description = S("Torch"),
drawtype = "nodebox",
tiles = {
{
name = "default_torch_ends.png",
},
{
name = "default_torch_ends.png",
},
{
name = "default_torch_base.png",
},
},
overlay_tiles = {
{ {
name = "default_torch_ends_overlay.png", name = "default_torch_ends_overlay.png",
animation = { animation = {
@ -121,13 +148,7 @@ minetest.register_node(
}, },
}, },
{ {
name = "default_torch_ends_overlay.png", name = "blank.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.0,
},
}, },
{ {
name = "default_torch_overlay.png", name = "default_torch_overlay.png",
@ -138,23 +159,12 @@ minetest.register_node(
length = 1.0, length = 1.0,
}, },
}, },
}, }
inventory_image = "default_torch_inventory.png", local overlayR90_weak = "default_torch_weak_overlayR90.png"
wield_image = "default_torch_inventory.png", local overlayR90_normal = "default_torch_overlayR90.png"
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
floodable = true,
light_source = default.LIGHT_MAX-1,
node_box = {
type = "wallmounted",
wall_top = {-2/16, 0, -2/16, 2/16, 0.5, 2/16},
wall_bottom = {-2/16, -0.5, -2/16, 2/16, 0, 2/16},
wall_side = {-0.5, -8/16, -2/16, -0.5+4/16, 0, 2/16},
},
groups = {choppy = 2, dig_immediate = 3, attached_node = 1},
is_ground_content = false,
sounds = default.node_sound_defaults(),
})
register_torch("torch_dead", S("Dead Torch"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, nil, nil, "default_torch_dead_inventory.png")
register_torch("torch_weak", S("Weak Torch"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, overlay_tiles_weak, overlayR90_weak, "default_torch_weak_inventory.png", default.LIGHT_MAX-4)
register_torch("torch", S("Torch"), {"default_torch_ends.png","default_torch_ends.png","default_torch_base.png"}, overlay_tiles_normal, overlayR90_normal, "default_torch_inventory.png", default.LIGHT_MAX-1)
default.log("torch", "loaded")