]> git.lizzy.rs Git - Crafter.git/blob - mods/redstone/player_detector.lua
bef44abb48e6f70e06246fb428fc0661dec902ca
[Crafter.git] / mods / redstone / player_detector.lua
1 local
2 minetest,ipairs,math
3 =
4 minetest,ipairs,math
5
6 --detects players and outputs accordingly
7 for i = 0,9  do
8
9 minetest.register_node("redstone:player_detector_"..i, {
10         description = "Redstone Player Detector",
11         drawtype = "normal",
12         tiles = {"player_detector.png"},
13         paramtype = "light",
14         paramtype2 = "none",
15         drop = "redstone:player_detector_0",
16         groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4, torch=1,redstone=1,redstone_torch=1,redstone_power=i, redstone_player_detection = 1},
17         legacy_wallmounted = true,
18         
19         on_construct = function(pos)
20                 redstone.inject(pos,{
21             name = "redstone:player_detector_"..i,
22             torch = i,
23                 })
24                 redstone.player_detector_add(pos)
25                 redstone.update(pos)
26         end,
27         on_destruct = function(pos, oldnode)
28                 redstone.player_detector_remove(pos)
29                 redstone.inject(pos,nil)
30                 redstone.update(pos)
31         end,
32         sounds = main.stoneSound(),
33 })
34
35 minetest.register_lbm({
36     name = "redstone:player_detector_"..i,
37     nodenames = {"redstone:player_detector_"..i},
38     run_at_every_load = true,
39     action = function(pos)
40         redstone.inject(pos,{
41             name = "redstone:player_detector_"..i,
42             torch = i,
43                 })
44                 redstone.player_detector_add(pos)
45     end,
46 })
47
48 end