Nike622000

AugenScanner

Oct 23rd, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1.  
  2. os.loadAPI("ocs/apis/sensor")
  3.  
  4. --peripherals
  5. local senSide = "bottom"
  6. local monSide = "back"
  7. --door opener
  8. local t1      = 4
  9. local Rside   = "left"
  10. --alert
  11. local t2      = 5
  12. local alert   = "top"
  13. --loop
  14. local t3      = 1
  15.  
  16. Player = {"Nike622000","jamawie"}
  17.  
  18. mon = peripheral.wrap(monSide)
  19. sen = sensor.wrap(senSide)
  20.  
  21. mon.setTextScale(.5)
  22.  
  23. local xMax,yMax = mon.getSize()
  24.  
  25. function Txt()
  26.   mon.setCursorPos(1,1)
  27.   mon.write("Bitte vor den")
  28.   mon.setCursorPos(1,2)
  29.   mon.write("Monitor stellen.")
  30. end
  31.  
  32. function Animation()
  33.   xPos  = {}
  34.   yPos  = {}
  35.   for i = 1,100 do
  36.     xPos[i]  = math.random(1,xMax)
  37.     yPos[i]  = math.random(4,yMax)
  38.     color = math.random(1,3)
  39.     x        = math.random(1,3)
  40.     if color == 1 then
  41.       col = colors.white
  42.     elseif color == 2 then
  43.       col = colors.lime
  44.     elseif color == 3 then
  45.       col = colors.green
  46.     end
  47.     mon.setTextColor(col)
  48.     mon.setCursorPos(xPos[i],yPos[i])
  49.     if x == 1 then
  50.       v = "0"
  51.     elseif x == 2 then
  52.       v = "1"
  53.     elseif x == 3 then
  54.       v = "2"
  55.     end
  56.     mon.write(v)
  57.   end
  58. end
  59.  
  60. function check()
  61.   ziele = sen.getTargets()
  62.   for k,v in pairs(ziele) do
  63.     if v.Name == "Player"
  64.     and v.Position.X <=  0.5 and v.Position.X >= -0.5
  65.     and v.Position.Y <=  2   and v.Position.Y >= -0.5
  66.     and v.Position.Z <=  2   and v.Position.Z >= 1
  67.     then
  68.       if sen.getTargetDetails(k).IsSneaking == true then
  69.         local found = false
  70.         for i = 1,#Player do
  71.           if k == Player[i] then
  72.             found = true
  73.           end
  74.         end
  75.         if found then
  76.           rs.setOutput(Rside,true)
  77.           sleep(t1)
  78.           rs.setOutput(Rside,false)
  79.         else
  80.           rs.setOutput(alert,true)
  81.           sleep(t2)
  82.           rs.setOutput(alert,false)
  83.         end
  84.       end
  85.     elseif v.Position.X <= 4.5 and v.Position.X >=  2.5
  86.     and    v.Position.Y <= 2.0 and v.Position.Y >= -1.0
  87.     and    v.Position.Z <= 3.5 and v.Position.Z >=  1.0
  88.     then
  89.       rs.setOutput(Rside,true)
  90.       sleep(t1)
  91.       rs.setOutput(Rside,false)
  92.     end
  93.   end
  94. end
  95.  
  96. while true do
  97. Txt()
  98. Animation()
  99. check()
  100. sleep(t3)
  101. end
Advertisement
Add Comment
Please, Sign In to add comment