Guest User

startup

a guest
Aug 13th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. peripheral.wrap("back")
  2. rednet.open("back")
  3.  
  4. logged = false
  5. user = " "
  6. pass = " "
  7.  
  8. function printList()
  9. print(" ")
  10. print("logout")
  11. print("toggle lift tb")
  12.  
  13. os.pullEvent("key")
  14. end
  15.  
  16. function unlog()
  17.   logged = false
  18.   user = " "
  19.   pass = " "
  20. end
  21.  
  22. function home()
  23.   term.clear()
  24.   term.setTextColor(colors.yellow)
  25.   term.setCursorPos(1,1)
  26.   print("Stendarr OS - TEXT ENABLED")
  27.   print("")
  28.   term.setTextColor(colors.white)
  29.   if logged == false then
  30.     logIn()
  31.   else
  32.     enterCommand()
  33.   end
  34. end
  35.  
  36. function logIn()
  37.  print("=====================")
  38.  print("| Enter Credentials |")
  39.  print("| Username:         |")
  40.  print("| Access Code:      |")
  41.  print("|                   |")
  42.  print("| Access:           |")
  43.  print("=====================")
  44.  term.setCursorPos(12, 5)
  45.  username = io.read()
  46.  term.setCursorPos(15, 6)
  47.  code = io.read()
  48.  if username == "WSearle" then
  49.    if code == "9465" then
  50.      user = "Will"
  51.      pass = "9465"
  52.      logged = true
  53.    end
  54.  elseif username == "RDucker" then
  55.    if code == "7245" then
  56.      user = "Rowan"
  57.      logged = true
  58.      pass = "7245"
  59.    end
  60.  end
  61.  term.setCursorPos(10, 8)
  62.  if logged == true then
  63.    term.setTextColor(colors.green)
  64.    term.write("Granted")  
  65.  else
  66.    term.setTextColor(colors.red)
  67.    term.write("Denied")
  68.  end
  69.  sleep(3)
  70. end
  71.  
  72. function enterCommand()
  73.   print("Welcome, " .. user)
  74.   print("Type 'list' for commands.")
  75.   print(" ")
  76.   command = io.read()
  77.   if command == "list" then
  78.     printList()
  79.   elseif command == "toggle lift tb" then
  80.     toggleLiftTB()
  81.   elseif command == "logout" then
  82.     unlog()
  83.   end    
  84. end
  85.  
  86. function toggleLiftTB()
  87.  print(" ")
  88.  print("Establishing connection...")
  89.  print("connect - " .. pass)
  90.  rednet.send(2,pass)
  91.  
  92.  local myTimer = os.startTimer(5)
  93.  
  94.    while true do
  95.      event,id,msg = os.pullEvent()
  96.      if event == "timer" then
  97.        print("Failed to Connect")
  98.        break    
  99.      
  100.      elseif event == "rednet_message" then
  101.        print("Confirmed")
  102.        rednet.send(2,"toggle")
  103.        break
  104.        
  105.      end      
  106.    end
  107.  os.pullEvent("key")
  108. end
  109.  
  110. while true do
  111.   home()
  112. end
Add Comment
Please, Sign In to add comment