Advertisement
Guest User

test

a guest
Oct 23rd, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. --[[ Luke Beesley & Co. Work in Progress - File Created: 23/10/2014 ]]--
  2.  
  3. --[[ INCLUDE FUNCTIONS ]]--
  4.  
  5. --[[ Function to center text within the monitor attached to the terminal, the calculation is mathematically correct, thus the text is centered, however it does not seem this way when viewed in game ]]--
  6. local function writeCenter(var, lineNo)
  7.  
  8.     local x, y = m.getSize()
  9.     local stringLength = string.len(var)
  10.     local center = (x / 2) - (stringLength / 2)
  11.     m.setCursorPos(center, lineNo)
  12.     m.write(var)
  13.  
  14. end
  15.  
  16. --[[ Function to prepare the monitor for data ]]--
  17. local function monitorReset()
  18.    
  19.     m.clear()
  20.     m.setCursorPos(1,1)
  21.     m.setTextColor(colors.white)
  22.        
  23. end
  24.  
  25. --[[ Function to prepare the terminal for data ]]--
  26. local function terminalReset()
  27.    
  28.     term.clear()
  29.     term.setCursorPos(1,1)
  30.     term.setTextColor(colors.white)
  31.        
  32. end
  33.  
  34. --[[ CHECK DEPENDANCES ]]--
  35.  
  36. --[[ Wrap the peripheral to the left of the computer ]]--
  37. if peripheral.isPresent("left") ~= true then
  38.    
  39.     terminalReset()
  40.     term.setTextColor(colors.red)
  41.     print("A monitor is not present to the left hand side of the terminal, please connect a monitor and let the program restart")
  42.     print("**If your program does not restart or you have an error press and hold 'CTRL + R' for 1 second")
  43.     print()
  44.     print("Restarting in 5...")
  45.     os.sleep(5)
  46.     term.clear()
  47.     os.sleep(1)
  48.     term.setCursorPos(1,1)
  49.     shell.run("test")
  50.    
  51. else
  52.  
  53. m = peripheral.wrap("left")
  54.  
  55. end
  56.  
  57. --[[ INITIALISE / DECLARE VARIABLES ]]--
  58.  
  59. --[[currently empty ]]--
  60.  
  61. --[[ START OF PROGRAM || DEPENDANCES CHECKED || FUNCTIONS INCLUDED || VARIABLES INITIALISED / DECLARED ]]--
  62.  
  63. monitorReset()
  64.  
  65. writeCenter("Welcome", 1)
  66. writeCenter("Please consult the terminal", 2)
  67. writeCenter("for more information", 3)
  68.  
  69. terminalReset()
  70. print("Welcome to the secrurity protocol 3000!")
  71. print("Please follow on screen instructions below to continue!")
  72. print()
  73. print("Welcome user please enter your password")
  74.  
  75. local input = read("*")
  76.  
  77. if "password" == input then
  78.    
  79.     terminalReset()
  80.     print("Thank you for inputting your password")
  81.     print()
  82.     print("Please wait...")
  83.     os.sleep(3)
  84.     print()
  85.     print("security protocol lowered, access granted")
  86.    
  87. else
  88.    
  89.     terminalReset()
  90.     print("Error you have inputted the wrong password!")
  91.     print("INTRUDER ALERT")
  92.     print("The Program will now restart for safety")
  93.     print()
  94.     print("Restarting in 5...")
  95.     os.sleep(5)
  96.     term.clear()
  97.     os.sleep(1)
  98.     term.setCursorPos(1,1)
  99.     shell.run("test")
  100.    
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement