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