Advertisement
123deg

Untitled

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