3 minetest,vector,math,pairs
5 minetest,vector,math,pairs
8 minetest.register_node("redstone:lever_on", {
9 description = "Lever On",
10 tiles = {"stone.png"},
11 groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
12 sounds = main.stoneSound(),
14 paramtype2 = "wallmounted",
15 sunlight_propagates = true,
18 drop="redstone:lever_off",
22 --left front bottom right back top
23 {-0.3, -0.5, -0.4, 0.3, -0.4, 0.4},
24 {-0.1, -0.5, 0.3, 0.1, 0, 0.1},
27 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
28 minetest.swap_node(pos, {name="redstone:lever_off",param2=node.param2})
30 minetest.sound_play("lever", {pos=pos})
32 local dir = minetest.wallmounted_to_dir(node.param2)
34 redstone.inject(pos,nil)
35 local pos2 = vector.add(dir,pos)
36 redstone.inject(pos2,nil)
41 after_destruct = function(pos, oldnode)
42 redstone.inject(pos,nil)
43 local dir = minetest.wallmounted_to_dir(oldnode.param2)
44 local pos2 = vector.add(dir,pos)
45 redstone.inject(pos2,nil)
54 minetest.register_node("redstone:lever_off", {
55 description = "Lever",
56 tiles = {"stone.png"},
57 groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
58 sounds = main.stoneSound(),
60 paramtype2 = "wallmounted",
61 sunlight_propagates = true,
64 drop="redstone:lever_off",
68 --left front bottom right back top
69 {-0.3, -0.5, -0.4, 0.3, -0.4, 0.4},
70 {-0.1, -0.5, -0.3, 0.1, 0, -0.1},
73 on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
74 minetest.swap_node(pos, {name="redstone:lever_on",param2=node.param2})
75 minetest.sound_play("lever", {pos=pos})
77 local dir = minetest.wallmounted_to_dir(node.param2)
79 redstone.inject(pos,{torch=9})
80 local pos2 = vector.add(dir,pos)
81 redstone.inject(pos2,{torch=9})
86 after_destruct = function(pos, oldnode)
87 redstone.inject(pos,nil)
88 local dir = minetest.wallmounted_to_dir(oldnode.param2)
89 local pos2 = vector.add(dir,pos)
90 redstone.inject(pos2,nil)