Advertisement
Plazter

Motion Sensor

Apr 13th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. component = require("component")
  2. motionSensor = component.motion_sensor
  3. colors = require("colors")
  4. sides = require("sides")
  5. event = require("event")
  6. redstone = component.redstone
  7.  
  8. side = sides.
  9. signal = colors.red
  10. args = {...}
  11. whitelist = {"player","player","player"}
  12.  
  13. function Check()
  14.  
  15. end
  16.  
  17. while true do
  18.     local _,_,x,y,z,player = event.pull("motion")
  19.         if args == "debug" then --text then
  20.             print("x: "..x)
  21.             print("y: "..y)
  22.             print("z: "..z)
  23.             print("player: ".. player)
  24.         end
  25.     Y = math.floor(y) -- the default over door is: -3
  26.         if x > -5 and x < 5 and Y >= -3 then
  27.             for k,v in pairs(whitelist) do
  28.                 if player == v then
  29.                     redstone.setBundledOutput(side,signal,15)
  30.                     os.sleep(2)
  31.                     redstone.setBundledOutput(side,signal,0)
  32.                     else
  33.                     redstone.setBundledOutput(side,signal,0)
  34.                 end
  35.             end
  36.         end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement