Guest User

Untitled

a guest
Oct 17th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. -- GLOBALS
  2. os.pullEvent = os.pullEventRaw -- prevents ctrl+t
  3. user = ""
  4. password = "beetlejuice"
  5. debug = "redux"
  6.  
  7. -- function definitions -------------------------------------
  8. function enterPassword( mon )
  9.     mon.write( "Enter password: " )
  10.     print( "Please enter password: " )
  11.  input = read( "*" )
  12.     if input == password then
  13.         print( "Please Enter" )
  14.   mon.clear()
  15.   mon.setCursorPos( 1, 5 )
  16.   mon.write( "Please Enter" )
  17.   user = "user"
  18.         return true
  19.     elseif input == debug then
  20.   print( "Hi Dave. You're looking good today" )
  21.   mon.clear()
  22.   mon.setCursorPos( 1, 5 )
  23.   mon.write( "Hi Dave." )
  24.   mon.setCursorPos( 1, 6 )
  25.   mon.write( " You're looking" )
  26.   mon.setCursorPos( 1, 7 )
  27.   mon.write( " good today." )
  28.         user = "poweruser"
  29.         return true
  30.     end
  31. return false
  32. end
  33.  
  34. function opendoor( user )
  35.     rs.setOutput( "top", false )
  36.     sleep( 0.5 )
  37.     rs.setOutput( "bottom", true )
  38. end
  39.  
  40. function closedoor()
  41.     rs.setOutput( "bottom", false )
  42.     sleep( 0.5 )
  43.     rs.setOutput( "top", true )
  44. end
  45.  
  46. -- program --------------------------------------------------
  47.  
  48. -- make sure door is shut
  49. closedoor()
  50.  
  51. -- clear the screen
  52. term.clear()
  53. -- setup monitor
  54. mon = peripheral.wrap( "left" )
  55. mon.clear()
  56. mon.setCursorPos( 1, 5 )
  57.  
  58. if enterPassword( mon ) then
  59.     opendoor( user )
  60. else
  61.  mon.clear()
  62.  mon.setCursorPos( 1, 5 )
  63.  mon.write( "Leave this place" )
  64.  mon.setCursorPos( 1, 6 )
  65.  mon.write( "and never return" )
  66.  print( "Leave this place and never return" )
  67. end
  68.  
  69. if user ~= "poweruser" then
  70.  sleep( 5 )
  71.  closedoor()
  72.     os.reboot()
  73. end
Add Comment
Please, Sign In to add comment