Advertisement
BlueMond

mainframe

Jan 1st, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.93 KB | None | 0 0
  1. local glass = peripheral.wrap("back")
  2. local version = 1.1
  3. local pass = "derpy"
  4. local isRunning = false
  5. local keepRunning = true
  6. local lastAction = "None"
  7. local lastCommand = "None"
  8. local byWho = "No one"
  9. local pTable = {}
  10. local nTable = {"313","315","316","100","99","317","318","283"}
  11.  
  12. function boot()
  13.     for x=1,#nTable do
  14.         pTable[x] = peripheral.wrap("computer_"..nTable[x])
  15.     end
  16.    
  17.     for x=1,#pTable do
  18.         pTable[x].turnOn()
  19.     end
  20. end
  21.  
  22. function os.pullEvent()
  23.     local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
  24.     if event == "terminate" then
  25.         if isRunning == false then
  26.             isRunning = true
  27.             shell.run("clear")
  28.             print("Incorrect Attempts will return you to main screen.")
  29.             write("Enter Password: ")
  30.             temp = read("*")
  31.             if temp ~= pass then
  32.                 isRunning = false
  33.                 --continue program
  34.             else
  35.                 if shell.getRunningProgram() == "startup" then
  36.                     keepRunning = false
  37.                     isRunning = false
  38.                 else
  39.                     isRunning = false
  40.                     shell.exit()
  41.                 end
  42.             end
  43.         end
  44.     end
  45.     return event, p1, p2, p3, p4, p5
  46. end
  47.  
  48.  
  49. rednet.open("right")
  50. boot()
  51. while keepRunning do
  52.     shell.run("clear")
  53.     print("~BlueTech~")
  54.     print("~Running Mainframe Control v"..version.."~")
  55.     print("~Terminate to access computer~")
  56.     print("")
  57.     print("Last Action: "..lastAction)
  58.     print("Last Command Receive: "..lastCommand)
  59.     print("Issued by: "..byWho)
  60.     event, com, pl = os.pullEvent()
  61.     if event == "chat_command" then
  62.         lastCommand = com
  63.         byWho = pl
  64.         lastAction = "Invalid Command"
  65.         if com == "doors" then
  66.             lastAction = "Doors temporarily opened"
  67.             rednet.broadcast("dToggle")
  68.             os.startTimer(5)
  69.         end
  70.         if com == "lights" then
  71.             lastAction = "Lights toggled"
  72.             rednet.broadcast("toggle")
  73.         end
  74.         if com == "blinds" then
  75.             lastAction = "Blinds toggled"
  76.             rednet.broadcast("bToggle")
  77.         end
  78.     end
  79.     if event == "timer" then
  80.         rednet.broadcast("dToggle")
  81.     end
  82. end
  83. shell.run("clear")
  84. print("~Welcome~") --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement