]> git.lizzy.rs Git - Crafter.git/blob - mods/redstone/torch.lua
6cd222bfe05a20b251898ca91f8de7c32ec09edf
[Crafter.git] / mods / redstone / torch.lua
1 local minetest,vector = minetest,vector
2
3 -- Item definitions
4 minetest.register_craftitem("redstone:torch", {
5         description = "Redstone Torch",
6         inventory_image = "redstone_torch.png",
7         wield_image = "redstone_torch.png",
8         wield_scale = {x = 1, y = 1, z = 1 + 1/16},
9         liquids_pointable = false,
10         power = 9,
11         on_place = function(itemstack, placer, pointed_thing)
12                 if pointed_thing.type ~= "node" then
13                         return itemstack
14                 end
15
16                 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
17
18                 local fakestack = itemstack
19                 local retval = false
20                 if wdir < 1 then
21                         return itemstack
22                 elseif wdir == 1 then
23                         retval = fakestack:set_name("redstone:torch_floor")
24                 else
25                         retval = fakestack:set_name("redstone:torch_wall")
26                 end
27                 if not retval then
28                         return itemstack
29                 end
30                 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
31                 itemstack:set_name("redstone:torch")
32
33                 if retval then
34                         minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
35                 end
36
37                 return itemstack
38         end
39 })
40
41 minetest.register_node("redstone:torch_floor", {
42         inventory_image = "redstone_torch.png",
43         wield_image = "redstone_torch.png",
44         wield_scale = {x = 1, y = 1, z = 1 + 2/16},
45         drawtype = "mesh",
46         mesh = "torch_floor.obj",
47         tiles = {"redstone_torch.png"},
48         paramtype = "light",
49         paramtype2 = "none",
50         power = 9,
51         sunlight_propagates = true,
52         drop = "redstone:torch",
53         walkable = false,
54         light_source = 13,
55         groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,redstone_power=9},
56         legacy_wallmounted = true,
57         selection_box = {
58                 type = "fixed",
59                 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
60         },
61         
62         on_construct = function(pos)
63                 redstone.inject(pos,{torch=9})
64                 redstone.update(pos)
65         end,
66         after_destruct = function(pos, oldnode)
67                 redstone.inject(pos,nil)
68                 redstone.update(pos)
69         end,
70         sounds = main.woodSound(),
71 })
72
73 minetest.register_node("redstone:torch_wall", {
74         inventory_image = "redstone_torch.png",
75         wield_image = "redstone_torch.png",
76         wield_scale = {x = 1, y = 1, z = 1 + 1/16},
77         drawtype = "mesh",
78         mesh = "torch_wall.obj",
79         tiles = {"redstone_torch.png"},
80         paramtype = "light",
81         paramtype2 = "wallmounted",
82         sunlight_propagates = true,
83         walkable = false,
84         light_source = 13,
85         power = 9,
86         groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,redstone_power=9},
87         drop = "redstone:torch",
88         selection_box = {
89                 type = "wallmounted",
90                 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
91                 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
92                 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
93         },
94         on_construct = function(pos)
95                 redstone.inject(pos,{torch=9})
96                 redstone.update(pos)
97         end,
98         after_destruct = function(pos, oldnode)
99                 redstone.inject(pos,nil)
100                 redstone.update(pos)
101         end,
102         sounds = main.woodSound(),
103 })
104
105
106 minetest.register_lbm({
107         name = "redstone:torch_init",
108         nodenames = {"redstone:torch_wall","redstone:torch_floor"},
109         run_at_every_load = true,
110         action = function(pos)
111                 redstone.inject(pos,{torch=9})
112         end,
113 })