Advertisement
Guest User

Untitled

a guest
May 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.76 KB | None | 0 0
  1. --[[ICBM Launch Server]]--
  2.  
  3. size = {term.getSize()}
  4.  
  5. users = {"Andrew2070"}
  6. passwords = {"3765"}
  7.  
  8. local silos = {}
  9. local data, curSilo = {}, 1
  10.  
  11. --[[Functions]]--
  12.  
  13. rednet.open("top")
  14. local waitDelay = 2
  15.  
  16. local function red()
  17. term.setBackgroundColor(colors.red)
  18. print(" ")
  19. term.setBackgroundColor(colors.blue)
  20. end
  21.  
  22.  
  23. function drawBoxPos(x,y,x1,y1)
  24. cy = y
  25. term.setCursorPos(x,y)
  26. for i = 1,(y1-y)+1 do
  27. for i = 1,(x1-x) do
  28. term.write(" ")
  29. end
  30. cy = cy+1
  31. term.setCursorPos(x,cy)
  32. end
  33. end
  34.  
  35. function reset()
  36. term.setBackgroundColor(colors.lightGray)
  37. term.setCursorPos(2,12)
  38. for i = 1,size[1]-4 do
  39. term.write(" ")
  40. end
  41. term.setTextColor(colors.gray)
  42. term.setBackgroundColor(colors.gray)
  43. drawBoxPos(9,8,size[1]-1,8)
  44. term.setBackgroundColor(colors.lightGray)
  45. term.setCursorPos(3,8)
  46. print("USER:")
  47. term.setBackgroundColor(colors.gray)
  48. drawBoxPos(9,10,size[1]-1,10)
  49. term.setBackgroundColor(colors.lightGray)
  50. term.setCursorPos(3,10)
  51. print("PASS:")
  52. end
  53.  
  54. function loginScreen()
  55. term.setBackgroundColor(colors.white)
  56. term.clear()
  57. term.setBackgroundColor(colors.lightGray)
  58. drawBoxPos(2,2,size[1],size[2]-1)
  59. term.setCursorPos(1,size[2]-7)
  60. term.setBackgroundColor(colors.gray)
  61. drawBoxPos(((size[1]/2)-10)-1,2,((size[1]/2)+13)-1,4)
  62. term.setBackgroundColor(colors.red)
  63. drawBoxPos((size[1]/2)-10,1,(size[1]/2)+13,3)
  64. term.setTextColor(colors.gray)
  65. str = "Skynet Mainframe"
  66. term.setCursorPos((size[1]/2)-(#str/2) +1,2)
  67. term.write(str)
  68. term.setBackgroundColor(colors.lightGray)
  69. str = "Enter Authentication Credentials"
  70. term.setCursorPos((size[1]/2)-(#str/2) +1,6)
  71. term.write(str)
  72. term.setBackgroundColor(colors.gray)
  73. drawBoxPos(9,8,size[1]-1,8)
  74. term.setBackgroundColor(colors.lightGray)
  75. term.setCursorPos(3,8)
  76. print("USER:")
  77. term.setBackgroundColor(colors.gray)
  78. drawBoxPos(9,10,size[1]-1,10)
  79. term.setBackgroundColor(colors.lightGray)
  80. term.setCursorPos(3,10)
  81. print("PASS:")
  82. term.setBackgroundColor(colors.red)
  83. drawBoxPos(((size[1]/2)-9)-1,13,((size[1]/2)+13)-1,15)
  84. term.setTextColor(colors.gray)
  85. str = "Login to Skynet!"
  86. term.setCursorPos((size[1]/2)-(#str/2) +1,14)
  87. term.write(str)
  88. term.setBackgroundColor(colors.lightGray)
  89. str = "(c) 2016 Skynet - Build. Innovate. Conquer"
  90. term.setCursorPos((size[1]/2)-(#str/2) +1,size[2]-2)
  91. term.write(str)
  92. while true do
  93. evnt = {os.pullEvent()}
  94. if evnt[1] == "mouse_click" then
  95. if evnt[3] > 8 and evnt[3] < size[1]-1 and evnt[4] == 8 then
  96. term.setBackgroundColor(colors.gray)
  97. term.setTextColor(colors.lightGray)
  98. term.setCursorPos(9,8)
  99. username = read()
  100. elseif evnt[3] > 8 and evnt[3] < size[1]-1 and evnt[4] == 10 then
  101. term.setBackgroundColor(colors.gray)
  102. term.setTextColor(colors.lightGray)
  103. term.setCursorPos(9,10)
  104. password = read("*")
  105. elseif evnt[3] > ((size[1]/2)-9)-2 and evnt[3] < ((size[1]/2)+13)-2 and evnt[4] > 12 and evnt[4] < 16 then
  106. if username ~= nil and password ~= nil then
  107. loggedin = false
  108. for i = 1,#users do
  109. if username == users[i] then
  110. if password == passwords[i] then
  111. term.setTextColor(colors.lime)
  112. term.setBackgroundColor(colors.lightGray)
  113. str = "Access Granted. Welcome back, "..username
  114. term.setCursorPos((size[1]/2)-(#str/2) +1,12)
  115. term.write(str)
  116. loggedin = true
  117. sleep(3)
  118. end
  119. end
  120. end
  121. if loggedin then
  122. term.setBackgroundColor(colors.blue)
  123. term.clear()
  124. term.setCursorPos(1,1)
  125. term.setBackgroundColor(colors.blue)
  126. term.clear()
  127.  
  128.  
  129.  
  130. rednet.broadcast("ping")
  131.  
  132. repeat
  133. local id, msg2 = rednet.receive(waitDelay)
  134. if type(msg2) == "table" and msg2.Msg == "pong" then
  135. table.insert(silos, msg2)
  136. table.insert(data, msg2.ID)
  137.  
  138. end
  139. until not id
  140. end
  141. term.clear()
  142. term.setCursorPos(1,1)
  143. print(" [Detected silos] ")
  144.  
  145.  
  146. for k, v in ipairs(silos) do
  147. print("[S#:".. k .."] [ID:" .. v.ID .."] [Type:".. v.Missile .. "] [Target:".. v.Target .. "]")
  148. end
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. red()
  157. write("Enter Launch Verification Code: ")
  158. input = read()
  159. red()
  160. term.setBackgroundColor(colors.blue)
  161. if input == "exit" then
  162. break
  163. elseif input == "949-854-3444" then
  164. while true do
  165. sleep(1)
  166. red()
  167. write("Launch Confirmation [Yes/No]: ")
  168. input2 = read()
  169. if input2 == "No" then
  170. os.reboot()
  171. elseif input2 == "Yes" then
  172. local count, x, y, z
  173. while not (type(count) == "number" and type(x) == "number" and type(y) == "number" and type(z) == "number") do
  174. red()
  175. print(" [Target Selection] ")
  176. red()
  177. term.setBackgroundColor(colors.blue)
  178. write(" Missile Count: ")
  179. count = tonumber(read())
  180. print("Coordinates:")
  181. write("X: ")
  182. x = tonumber(read())
  183. write("Y: ")
  184. y = tonumber(read())
  185. write("Z: ")
  186. z = tonumber(read())
  187. sleep(1)
  188. print(" Target Selection Complete:")
  189. red()
  190. term.setBackgroundColor(colors.blue)
  191. print("Launching at: "..x..","..y..","..z)
  192. print("Launching Missiles -T Minus 10 Seconds.")
  193. sleep(1)
  194. red()
  195.  
  196. sleep(1)
  197. write(" Abort [Yes/No]: ")
  198. local abort = read()
  199. if abort == "Yes" then
  200. write("Warheads Disarmed Successfully")
  201. sleep(1)
  202. write("Session Expired, renewing login:")
  203. sleep(2)
  204. os.reboot()
  205. elseif abort == "No" then
  206. end
  207. local msg = {["x"] = x, ["y"] = y, ["z"] = z}
  208. print("launching Missiles At " .. x .. ", " .. y .. ", " .. z)
  209. for i = 1, count do
  210. rednet.send(data[curSilo], msg)
  211. curSilo = (curSilo == #data) and 1 or (curSilo + 1)
  212. sleep(5)
  213. end
  214. sleep(10)
  215. os.reboot()
  216. end
  217. elseif loggedin == false then
  218. term.setTextColor(colors.red)
  219. term.setBackgroundColor(colors.lightGray)
  220. str = "Username or Password incorrect."
  221. term.setCursorPos((size[1]/2)-(#str/2) +1,12)
  222. term.write(str)
  223. sleep(2)
  224. reset()
  225. end
  226. end
  227. elseif username == nil or password == nil then
  228. reset()
  229. term.setTextColor(colors.red)
  230. term.setBackgroundColor(colors.lightGray)
  231. str = "Username or Password not recognized."
  232. term.setCursorPos((size[1]/2)-(#str/2) +1,12)
  233. term.write(str)
  234. sleep(2)
  235. reset()
  236. end
  237. end
  238. end
  239. end
  240. end
  241. end
  242.  
  243.  
  244. loginScreen()
  245. term.setBackgroundColor(colors.black)
  246. term.clear()
  247. term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement