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