Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.14 KB | None | 0 0
  1. sleep(3)
  2.  
  3. local mon = peripheral.wrap("back")
  4. local oldPull = os.pullEvent
  5. os.pullEvent = os.pullEventRaw
  6.  
  7. function mwrite(txt)
  8.   mon.clear()
  9.   mon.setCursorPos(1,2)
  10.   mon.setTextScale(2)
  11.   mon.write("--- Klungelsoft ---")
  12.   sleep(1)
  13.   mon.clear()
  14.   mon.setCursorPos(1,2)
  15.   mon.write(txt)
  16. --  mon1.write(string.len(txt))
  17. end
  18.  
  19. function loop()
  20.   while true do
  21.     mwrite("---  Town shop  ---")
  22.     sleep(1)
  23.   end
  24. end
  25.  
  26. function menu()
  27.   print("start or stop?")
  28.   if read()=="start" then
  29.     loop()
  30.   end
  31.   os.pullEvent = oldPull
  32. --  shell.exit()
  33. end
  34.  
  35. function login2()
  36.   mwrite("---  Town shop  ---")
  37.   term.clear()
  38.   term.setCursorPos(1,1)
  39.   print("Press a key to unlock the computer")
  40.   os.startTimer(1)
  41.   event, param1, param2, param3 = os.pullEvent()
  42. --  print(event)
  43.   if event=="key" then
  44.     print("starting login")
  45.     login()
  46.   else
  47.     print("No key pressed. Starting normal program")
  48.     loop()
  49.   end
  50. end
  51.  
  52. function login()
  53.   term.clear()
  54.   term.setCursorPos(1,1)
  55.   print("Press the first letter of the pass")
  56.   os.startTimer(10)
  57.   event, param1, param2, param3 = os.pullEvent()
  58. --  print(param1)
  59. --  print(event)
  60. --  print(event=="key")
  61. --  print(param1=="30")
  62. --  print(param1)
  63. --  print(param1==30)
  64. --  print(param1=="a")
  65.   if event=="key" and param1==30 then
  66.     print("Press the second letter of the pass")
  67.     event, param1, param2, param3 = os.pullEvent()
  68. --    print(param1)
  69. --    print(event)
  70.     event, param1, param2, param3 = os.pullEvent()
  71. --    print(param1)
  72. --    print(event)
  73.     if event=="key" and param1==30 then
  74.       print("Press the final letter of the pass")
  75.       event, param1, param2, param3 = os.pullEvent()
  76. --      print(param1)
  77. --      print(event)
  78.       event, param1, param2, param3 = os.pullEvent()
  79.       if event=="key" and param1==25 then
  80.         event, param1, param2, param3 = os.pullEvent()
  81.         print("Passcode accepted")
  82.         menu()
  83.       else
  84.         denied()
  85.       end
  86.     else
  87.       denied()
  88.     end
  89.   else
  90.     denied()
  91.   end
  92. end
  93.  
  94. function denied()
  95.   print("Passcode denied")
  96.   print("Starting normal program")
  97.   loop()
  98. end
  99.  
  100. login2()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement