Advertisement
Guest User

startup

a guest
Sep 21st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. rednet.open("back")
  2.  
  3. local protocol = "gate-security"
  4. local hostname = "server"
  5. local password = "secure"
  6. local opentime = 5
  7. local monitor = peripheral.wrap("top")
  8.  
  9. redstone.setOutput("bottom", true)
  10. monitor.setBackgroundColor(colors.lime)
  11. monitor.clear()
  12.  
  13.  
  14. rednet.host(protocol, hostname)
  15.  
  16. local function opengate()
  17.   redstone.setOutput("bottom", false)
  18.   sleep(opentime)
  19.   redstone.setOutput("bottom", true)
  20. end
  21.  
  22. local function receiveRednet()
  23.   local id, message, protocol = rednet.receive()
  24.  
  25.   print(tostring(id))
  26.   print(tostring(message))
  27.      
  28.   if tostring(message) == password then
  29.     print("rednet, opengate")
  30.     opengate()
  31.   end
  32. end
  33.  
  34. local function receiveTouch()
  35.   local event = os.pullEvent("monitor_touch")
  36.  
  37.   print("monitor, opengate")
  38.  
  39.   monitor.setBackgroundColor(colors.red)
  40.   monitor.clear()
  41.   opengate()
  42.   monitor.setBackgroundColor(colors.lime)
  43.   monitor.clear()
  44. end
  45.  
  46. while true do
  47.   parallel.waitForAny(receiveRednet, receiveTouch)
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement