csmit195

Tekkit Machine Room Door Close

Jul 16th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. local radar, currentSecond, lastInput = peripheral.wrap('radar_0'), 0, 0
  2.  
  3. function initiate()
  4.     while true do
  5.         loop()
  6.         currentSecond = currentSecond + 1
  7.         sleep(1)
  8.     end
  9. end
  10.  
  11. function loop()
  12.     -- Every 2 Seconds to reduce amount of sensor calls and potentially limit lag
  13.     if ( currentSecond % 2 == 0 ) then
  14.         -- Probe Sensors
  15.         local isInside
  16.         for index, player in ipairs(radar.getPlayers()) do
  17.             if ( player.distance < 5.5 ) then
  18.                 isInside = true
  19.                 break
  20.             end
  21.         end
  22.         term.setCursorBlink(true)
  23.         rs.setOutput('bottom', not isInside)
  24.         term.setCursorBlink(false)
  25.     end
  26. end
  27.  
  28. initiate()
Advertisement
Add Comment
Please, Sign In to add comment