Guest User

defcon

a guest
Oct 28th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.91 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(22,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.    rednetApi()
  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. r()
  179. term.setCursorPos(1,2)
  180. term.setTextColor(colors.red)
  181. print("Welcome to the Rednet API! Here you can send")
  182. print("infomation wirelessly to computers.")
  183. print("Enter a rednet code or enter exit() to")
  184. print("return to main menu.")
  185. end
  186.  
  187. function rednetApi()
  188. rednetApiText()
  189. input=read()
  190.  if input==("send")then
  191.  rednetSide()
  192.  rednetSend()
  193.  elseif input==("exit()") then
  194.  apiRead()
  195.  elseif input==("broadcast") then
  196.  rednetSide()
  197.  broadcast()
  198.  else print("Error:Rednet code not found")
  199.  rednetApiText()
  200.  rednetApi()
  201.    end
  202. end
  203.  
  204. function rednetSide()
  205. term.clear()
  206. term.setCursorPos(1,1)
  207.  if fs.isDir("top") then
  208.  n="top"
  209.  rednet.close(n)
  210.  rednet.open(n)
  211.  rednetApi()
  212.  elseif fs.isDir("bottom") then
  213.  n="bottom"
  214.  rednet.close(n)
  215.  rednet.open(n)
  216.  rednetApi()
  217.  elseif fs.isDir("left") then
  218.  n="left"
  219.  rednet.close(n)
  220.  rednet.open(n)
  221.  rednetApi()
  222.  elseif fs.isDir("right") then
  223.  n="right"
  224.  rednet.close(n)
  225.  rednet.open(n)
  226.  rednetApi()
  227.  elseif fs.isDir("front") then
  228.  n="front"
  229.  rednet.close(n)
  230.  rednet.open(n)
  231.  rednetApi()
  232.  elseif fs.isDir("back") then
  233.  R="back"
  234.  rednet.close(n)
  235.  rednet.open(n)
  236.  rednetApi()
  237. end
  238. end
  239.  
  240.  
  241.  
  242. function broadcast()
  243. print("Whats your Message?")
  244. input=read()
  245. rednet.close(n)
  246. rednet.open(n)
  247. rednet.broadcast(input)
  248. sleep(0.75)
  249. rednet.broadcast(input)
  250. sleep(0.75)
  251. rednet.broadcast(input)
  252. print("Message Broadcasted!")
  253. rednetApi()
  254. end
  255.  
  256.  
  257.  
  258.  
  259. --rednet api end
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266. function raiseDefconLevel()
  267.  if fs.isDir("defcon5") then
  268.  fs.delete("defcon5/")
  269.  fs.makeDir("defcon4")
  270.  term.clear()
  271.  r()
  272.  apiText()
  273.  apiRead()
  274.  elseif fs.isDir("defcon4") then
  275.  fs.delete("defcon4/")
  276.  fs.makeDir("defcon3")
  277.  term.clear()
  278.  r()
  279.  apiText()
  280.  apiRead()
  281.  elseif fs.isDir("defcon3") then
  282.  fs.delete("defcon3/")
  283.  fs.makeDir("defcon2")
  284.  term.clear()
  285.  r()
  286.  apiText()
  287.  apiRead()
  288.  elseif fs.isDir("defcon2") then
  289.  fs.delete("defcon2/")
  290.  fs.makeDir("defcon1")
  291.  term.clear()
  292.  r()
  293.  apiText()
  294.  apiRead()
  295.  elseif fs.isDir("defcon1") then
  296.  term.setTextColor(colors.red)
  297.  print("Error: Is at Defcon 1")
  298.  r()
  299.  apiText()
  300.  apiRead()
  301.  else
  302.  print("Error: Defcon has no current value")
  303.  r()
  304.  apiText()
  305.  apiRead()
  306.  end
  307. end
  308.  
  309. function lowerDefconLevel()
  310.  if fs.isDir("defcon1") then
  311.  fs.delete("defcon1/")
  312.  fs.makeDir("defcon2")
  313.  term.clear()
  314.  r()
  315.  apiText()
  316.  apiRead()
  317.  elseif fs.isDir("defcon2") then
  318.  fs.delete("defcon2/")
  319.  fs.makeDir("defcon3")
  320.  term.clear()
  321.  r()
  322.  apiText()
  323.  apiRead()
  324.  elseif fs.isDir("defcon3") then
  325.  fs.delete("defcon3/")
  326.  fs.makeDir("defcon4")
  327.  term.clear()
  328.  r()
  329.  apiText()
  330.  apiRead()
  331.  elseif fs.isDir("defcon4") then
  332.  fs.delete("defcon4/")
  333.  fs.makeDir("defcon5")
  334.  term.clear()
  335.  r()
  336.  apiText()
  337.  apiRead()
  338.  elseif fs.isDir("defcon5") then
  339.  print("Error : Is at defcon 5")
  340.  sleep(0.75)
  341.  term.clear()
  342.  r()
  343.  apiText()
  344.  apiRead()
  345.  else print("Error : Defcon had no value")
  346.  sleep(0.75)
  347.  term.clear()
  348.  r()
  349.  apiText()
  350.  apiRead()
  351.  end
  352. end
  353. --Running code
  354. function defcon()
  355. drawScreen()
  356. drawLoginBox()
  357. drawLoginText()
  358. usernameInput()
  359. warning()
  360. end
  361.  
  362. function defcon2()
  363.  
  364. defconDetermine()
  365. r()
  366. apiRead()
  367. apiText()
  368. end
  369. apiText()
  370. apiRead()
Advertisement
Add Comment
Please, Sign In to add comment