4 Torch mod - formerly mod "Torches"
7 (c) Copyright BlockMen (2013-2015)
8 (C) Copyright sofar <sofar@foo-projects.org> (2016)
10 This mod changes the default torch drawtype from "torchlike" to "mesh",
11 giving the torch a three dimensional appearance. The mesh contains the
12 proper pixel mapping to make the animation appear as a particle above
13 the torch, while in fact the animation is just the texture of the mesh.
18 (c) Copyright BlockMen (2013-2015)
20 Textures and Meshes/Models:
22 Note that the models were entirely done from scratch by sofar.
25 Licensed under the GNU LGPL version 2.1 or higher.
26 You can redistribute it and/or modify it under
27 the terms of the GNU Lesser General Public License
28 as published by the Free Software Foundation;
30 You should have received a copy of the GNU Lesser General Public
31 License along with this library; if not, write to the Free Software
32 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
34 See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt
38 minetest.register_node("default:torch", {
39 description = "Torch",
41 mesh = "torch_floor.obj",
42 inventory_image = "default_torch_on_floor.png",
43 wield_image = "default_torch_on_floor.png",
45 name = "default_torch_on_floor_animated.png",
46 animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
49 paramtype2 = "wallmounted",
50 sunlight_propagates = true,
52 liquids_pointable = false,
54 groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1},
55 drop = "default:torch",
58 wall_bottom = {-1/8, -1/2, -1/8, 1/8, 2/16, 1/8},
60 sounds = default.node_sound_wood_defaults(),
61 on_place = function(itemstack, placer, pointed_thing)
62 local under = pointed_thing.under
63 local node = minetest.get_node(under)
64 local def = minetest.registered_nodes[node.name]
65 if def and def.on_rightclick and
66 ((not placer) or (placer and not placer:get_player_control().sneak)) then
67 return def.on_rightclick(under, node, placer, itemstack,
68 pointed_thing) or itemstack
71 local above = pointed_thing.above
72 local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
73 local fakestack = itemstack
75 fakestack:set_name("default:torch_ceiling")
77 fakestack:set_name("default:torch")
79 fakestack:set_name("default:torch_wall")
82 itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
83 itemstack:set_name("default:torch")
89 minetest.register_node("default:torch_wall", {
91 mesh = "torch_wall.obj",
93 name = "default_torch_on_floor_animated.png",
94 animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
97 paramtype2 = "wallmounted",
98 sunlight_propagates = true,
101 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
102 drop = "default:torch",
104 type = "wallmounted",
105 wall_side = {-1/2, -1/2, -1/8, -1/8, 1/8, 1/8},
107 sounds = default.node_sound_wood_defaults(),
110 minetest.register_node("default:torch_ceiling", {
112 mesh = "torch_ceiling.obj",
114 name = "default_torch_on_floor_animated.png",
115 animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
118 paramtype2 = "wallmounted",
119 sunlight_propagates = true,
122 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
123 drop = "default:torch",
125 type = "wallmounted",
126 wall_top = {-1/8, -1/16, -5/16, 1/8, 1/2, 1/8},
128 sounds = default.node_sound_wood_defaults(),
131 minetest.register_lbm({
132 name = "default:3dtorch",
133 nodenames = {"default:torch", "torches:floor", "torches:wall"},
134 action = function(pos, node)
135 if node.param2 == 0 then
136 minetest.set_node(pos, {name = "default:torch_ceiling",
137 param2 = node.param2})
138 elseif node.param2 == 1 then
139 minetest.set_node(pos, {name = "default:torch",
140 param2 = node.param2})
142 minetest.set_node(pos, {name = "default:torch_wall",
143 param2 = node.param2})