Advertisement
Guest User

startup

a guest
May 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. local pullEvent = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3. local modem = "right"
  4. local cpid = 4
  5. local cpmsg = "open my door"
  6. local side = "back"
  7. local password = "welcome to my house"
  8. local debug = "debug pass"
  9. local opentime = 5
  10. rednet.open(modem)
  11. function main_loop()
  12.   while true do
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15.     print("Mot de passe: ")
  16.     local input = read()
  17.     if input == password then
  18.       term.clear()
  19.       term.setCursorPos(1,1)
  20.       print("Bienvenue chez vous !")
  21.       rs.setOutput(side,true)
  22.       sleep(opentime)
  23.       rs.setOutput(side,false)
  24.       os.reboot()
  25.     end
  26.     if input == debug then
  27.       term.clear()
  28.       term.setCursorPos(1,1)
  29.       print("Debug Enabled")
  30.       os.pullEvent = pullEvent
  31.     else
  32.       print("Mot de passe incorecte !")
  33.       sleep(2)
  34.     end
  35.   end
  36. end
  37.  
  38. function rednet_open()
  39.   while true do
  40.     id,msg = rednet.receive()
  41.     if id == cpid and msg == cpmsg then
  42.       term.clear()
  43.       term.setCursorPos(1,1)
  44.       print("Porte ouverte")
  45.       rs.setOutput(side,true)
  46.       sleep(opentime)
  47.       rs.setOutput(side,false)
  48.       rednet.close(modem)
  49.       os.reboot()
  50.     end
  51.   end
  52. end
  53. parallel.waitForAny(rednet_open,main_loop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement