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