Guest User

defcon

a guest
Oct 27th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.60 KB | None | 0 0
  1. x=5
  2. --Inital Screen
  3. function drawScreen()
  4. shell.run("draw")
  5. sleep(0.75)
  6. term.clear()
  7. term.setBackgroundColor(colors.white)
  8. term.setTextColor(colors.red)
  9. end
  10.  
  11. function drawLoginBox()
  12. term.setTextColor(colors.black)
  13. term.setCursorPos(9,2)
  14. print("  ----------------------------------  ")
  15. term.setCursorPos(9,3)
  16. print(" |                                  | ")
  17. term.setCursorPos(9,4)
  18. print(" |                                  | ")
  19. term.setCursorPos(9,5)
  20. print(" |                                  | ")
  21. term.setCursorPos(9,6)
  22. print(" |                                  | ")
  23. term.setCursorPos(9,7)
  24. print("  ----------------------------------  ")
  25. end
  26.  
  27. function drawLoginText()
  28. term.setCursorPos(12,4)
  29. print("Username:")
  30. term.setCursorPos(12,6)
  31. print("Password:")
  32. end
  33.  
  34. function usernameInput()
  35. term.setCursorPos(22,4)
  36. input=read()
  37.  if input == ("kai") then
  38.  passwordInput()
  39.   elseif input == ("kaioo") then
  40.   passwordInput()
  41.   elseif input == ("kaioo132") then
  42.   passwordInput()
  43.   else
  44.   term.clear()
  45.   term.setCursorPos(1,1)
  46.   print("Username Incorrect")
  47.   sleep(0.75)
  48.   term.clear()
  49.   drawLoginBox()
  50.   drawLoginText()
  51.   usernameInput()
  52.   end
  53.  end
  54.  
  55. function passwordInput()
  56. term.setCursorPos(22,6)
  57. input=read("*")
  58.  if input == ("nuke") then
  59.  term.clear()
  60.   else
  61.   term.clear()
  62.   term.setCursorPos(1,1)
  63.   print("Password Incorrect")
  64.   sleep(0.75)
  65.   term.clear()
  66.   term.setCursorPos(21,4)
  67.   term.setTextColor(colors.black)
  68.   print("kai")
  69.   drawLoginBox()
  70.   drawLoginText()
  71.   term.setCursorPos(21,4)
  72.   print("kai")
  73.   passwordInput()
  74.   end
  75.  end
  76.  
  77. function warning()
  78. shell.run("clear")
  79. print("Warning! This program is illegal to run")
  80. print("on unautharized pc's. This is a system")
  81. print("designed for Blue Task (R). Press the")
  82. print("F1 key to continue.")
  83.  while true do
  84.  event,p1 = os.pullEvent()
  85.   if (event=="key") and (p1==59) then
  86.   defcon2()
  87.    end
  88.  end
  89. end
  90. --Inital Screen End
  91. --Defcon Determine
  92.  
  93. function defconDetermine()
  94. term.setBackgroundColor(colors.white)
  95. term.clear()
  96. term.setBackgroundColor(colors.white)
  97. term.setTextColor(7)
  98.  if fs.exists("defcon5") then
  99.  print("You are at Defcon 5")
  100.  elseif fs.isDir("defcon4") then
  101.  print("You are at Defcon 4")
  102.  x=x-1
  103.  elseif fs.isDir("defcon3") then
  104.  print("You are at Defcon 3")
  105.  x=x-2
  106.  elseif fs.isDir("defcon2") then
  107.  print("You are at Defcon 2")
  108.  x=x-3
  109.  elseif fs.isDir("defcon1") then
  110.  print("You are at Defcon 1")
  111.  x=x-4
  112.  else
  113.  print("You are at Defcon 5")
  114.  fs.makeDir("defcon5")
  115.   end
  116. end
  117. --Defcon Determine End--
  118. --API--
  119. function r()
  120. term.setBackgroundColor(colors.white)
  121. term.clear()
  122. term.setCursorPos(1,1)
  123. term.setBackgroundColor(colors.white)
  124. term.setTextColor(colors.black)
  125.  if fs.isDir("defcon5") then
  126.  s=5
  127.  elseif fs.isDir("defcon4") then
  128.  s=4
  129.  elseif fs.isDir("defcon3") then
  130.  s=3
  131.  elseif fs.isDir("defcon2") then
  132.  s=2
  133.  elseif fs.isDir("defcon1") then
  134.  s=1
  135.  else fs.makeDir("defcon5")
  136.  r()
  137.  end
  138. term.clear()
  139. term.setTextColor(colors.black)
  140. print("You are at Defcon  ")
  141. term.setCursorPos(19,1)
  142. print(s)
  143. end
  144. function apiText()
  145. term.clear()
  146. term.setBackgroundColor(colors.white)
  147. term.setTextColor(colors.black)
  148. term.clear()
  149. r()
  150. term.setCursorPos(1,2)
  151. print("Enter a command to be executed")
  152. print("Enter exit() to exit()")
  153. end
  154.  
  155. function apiRead()
  156. apiText()
  157. input=read()
  158.  if input==("show defcon level") then
  159.  r()
  160.   elseif input==("raise defcon level") then
  161.   defconDetermine()
  162.   raiseDefconLevel()
  163.    elseif input==("lower defcon level") then
  164.    defconDetermine()
  165.    lowerDefconLevel()
  166.    elseif input==("rednet") then
  167.    rednetSide()
  168.    
  169.    elseif input==("exit()") then
  170.    os.reboot()
  171.    else print("Command does not exist!")  
  172.     apiRead()
  173.       end
  174.   end
  175. --rednet api
  176. function rednetApiText()
  177. shell.run("clear")
  178. term.setCursorPos(1,2)
  179. term.setTextColor(colors.red)
  180. print("Welcome to the Rednet API! Here you can send")
  181. print("infomation wirelessly to computers.")
  182. print("Enter a rednet code or enter exit() to")
  183. print("return to main menu.")
  184. end
  185.  
  186. function rednetApi()
  187. rednetApiText()
  188. r()
  189. input=read()
  190.  if input==send then
  191.  rednetSide()
  192.  rednetSend()
  193. elseif input==("exit") then
  194. apiRead()
  195.  end
  196. end
  197.  
  198. function rednetSend()
  199. input=read()
  200. id=input
  201. input=read()
  202. message=input
  203. rednet.send(id,message)
  204. end
  205.  
  206.  
  207.  
  208.  
  209.  
  210. function rednetSide()
  211. term.clear()
  212. term.setCursorPos(1,1)
  213.  if fs.isDir("top") then
  214.  r="top"
  215.  rednet.close(r)
  216.  rednet.open(r)
  217.  rednetApi()
  218.  elseif fs.isDir("bottom") then
  219.  r="bottom"
  220.  rednet.close(r)
  221.  rednet.open(r)
  222.  rednetApi()
  223.  elseif fs.isDir("left") then
  224.  r="left"
  225.  rednet.close(r)
  226.  rednet.open(r)
  227.  rednetApi()
  228.  elseif fs.isDir("right") then
  229.  r="right"
  230.  rednet.close(r)
  231.  rednet.open(r)
  232.  rednetApi()
  233.  elseif fs.isDir("front") then
  234.  r="front"
  235.  rednet.close(r)
  236.  rednet.open(r)
  237.  rednetApi()
  238.  elseif fs.isDir("back") then
  239.  r="back"
  240.  rednet.close(r)
  241.  rednet.open(r)
  242.  rednetApi()
  243. end
  244. end
  245.  
  246. --rednet api end
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253. function raiseDefconLevel()
  254.  if fs.isDir("defcon5") then
  255.  fs.delete("defcon5/")
  256.  fs.makeDir("defcon4")
  257.  term.clear()
  258.  r()
  259.  apiText()
  260.  apiRead()
  261.  elseif fs.isDir("defcon4") then
  262.  fs.delete("defcon4/")
  263.  fs.makeDir("defcon3")
  264.  term.clear()
  265.  r()
  266.  apiText()
  267.  apiRead()
  268.  elseif fs.isDir("defcon3") then
  269.  fs.delete("defcon3/")
  270.  fs.makeDir("defcon2")
  271.  term.clear()
  272.  r()
  273.  apiText()
  274.  apiRead()
  275.  elseif fs.isDir("defcon2") then
  276.  fs.delete("defcon2/")
  277.  fs.makeDir("defcon1")
  278.  term.clear()
  279.  r()
  280.  apiText()
  281.  apiRead()
  282.  elseif fs.isDir("defcon1") then
  283.  term.setTextColor(colors.red)
  284.  print("Error: Is at Defcon 1")
  285.  r()
  286.  apiText()
  287.  apiRead()
  288.  else
  289.  print("Error: Defcon has no current value")
  290.  r()
  291.  apiText()
  292.  apiRead()
  293.  end
  294. end
  295.  
  296. function lowerDefconLevel()
  297.  if fs.isDir("defcon1") then
  298.  fs.delete("defcon1/")
  299.  fs.makeDir("defcon2")
  300.  term.clear()
  301.  r()
  302.  apiText()
  303.  apiRead()
  304.  elseif fs.isDir("defcon2") then
  305.  fs.delete("defcon2/")
  306.  fs.makeDir("defcon3")
  307.  term.clear()
  308.  r()
  309.  apiText()
  310.  apiRead()
  311.  elseif fs.isDir("defcon3") then
  312.  fs.delete("defcon3/")
  313.  fs.makeDir("defcon4")
  314.  term.clear()
  315.  r()
  316.  apiText()
  317.  apiRead()
  318.  elseif fs.isDir("defcon4") then
  319.  fs.delete("defcon4/")
  320.  fs.makeDir("defcon5")
  321.  term.clear()
  322.  r()
  323.  apiText()
  324.  apiRead()
  325.  elseif fs.isDir("defcon5") then
  326.  print("Error : Is at defcon 5")
  327.  sleep(0.75)
  328.  term.clear()
  329.  r()
  330.  apiText()
  331.  apiRead()
  332.  else print("Error : Defcon had no value")
  333.  sleep(0.75)
  334.  term.clear()
  335.  r()
  336.  apiText()
  337.  apiRead()
  338.  end
  339. end
  340. --Running code
  341. function defcon()
  342. drawScreen()
  343. drawLoginBox()
  344. drawLoginText()
  345. usernameInput()
  346. warning()
  347. end
  348.  
  349. function defcon2()
  350.  
  351. defconDetermine()
  352. r()
  353. apiRead()
  354. apiText()
  355. end
  356. defcon()
Advertisement
Add Comment
Please, Sign In to add comment