SHOW:
|
|
- or go back to the newest paste.
| 1 | - | --[[ICBM Launch Server]]-- |
| 1 | + | --[Skynet Nuclear Defense Program by Andrew2060]-- |
| 2 | - | |
| 2 | + | --[To be used with http://pastebin.com/exm7HRhr]-- |
| 3 | - | size = {term.getSize()}
|
| 3 | + | |
| 4 | - | |
| 4 | + | --[[Settings]]-- |
| 5 | - | users = {"Andrew2070"}
|
| 5 | + | |
| 6 | - | passwords = {"3765"}
|
| 6 | + | |
| 7 | - | |
| 7 | + | --[[Init]]-- |
| 8 | local silos = {}
| |
| 9 | - | |
| 9 | + | peripheral.find("modem", rednet.open)
|
| 10 | --[[Functions]]-- | |
| 11 | local accounts = {
| |
| 12 | - | rednet.open("top")
|
| 12 | + | ["Andrew2070"] = "35851562", |
| 13 | ["Jack202020"] = "1-800-jack" | |
| 14 | ||
| 15 | - | local function red() |
| 15 | + | } |
| 16 | - | term.setBackgroundColor(colors.red) |
| 16 | + | |
| 17 | - | print(" ")
|
| 17 | + | local function clear() |
| 18 | term.clear() | |
| 19 | term.setCursorPos(1, 1) | |
| 20 | end | |
| 21 | ||
| 22 | - | rednet.broadcast("ping silo")
|
| 22 | + | |
| 23 | - | |
| 23 | + | clear() |
| 24 | ||
| 25 | - | |
| 25 | + | |
| 26 | rednet.broadcast("ping silo")
| |
| 27 | ||
| 28 | - | |
| 28 | + | |
| 29 | ||
| 30 | while true do | |
| 31 | event, id, msg, distance = os.pullEvent() | |
| 32 | ||
| 33 | if event == "rednet_message" and msg == "pong" then | |
| 34 | table.insert(silos, id) | |
| 35 | timerID = os.startTimer(waitDelay) | |
| 36 | elseif event == "timer" and id == timerID then | |
| 37 | - | |
| 37 | + | |
| 38 | end | |
| 39 | end | |
| 40 | end | |
| 41 | - | print("launching Missiles At " .. x .. ", " .. y .. ", " .. z)
|
| 41 | + | |
| 42 | local curSilo = 1 | |
| 43 | local function launch(count, x, y, z) | |
| 44 | local msg = {x = x, y = y, z = z}
| |
| 45 | print("Launching @ " .. x .. ", " .. y .. ", " .. z)
| |
| 46 | for i = 1, count do | |
| 47 | sleep(1) | |
| 48 | - | |
| 48 | + | |
| 49 | curSilo = (curSilo == #silos) and 1 or (curSilo + 1) | |
| 50 | sleep(5) | |
| 51 | - | term.setCursorPos(1,1) |
| 51 | + | |
| 52 | - | print(" [Detected silos] ")
|
| 52 | + | |
| 53 | ||
| 54 | - | print(" silo #" .. k .. " id = "..v)
|
| 54 | + | |
| 55 | clear() | |
| 56 | print("==========================")
| |
| 57 | - | |
| 57 | + | print(" [Detected Silos] ")
|
| 58 | - | function drawBoxPos(x,y,x1,y1) |
| 58 | + | |
| 59 | - | cy = y |
| 59 | + | print(" silo #" .. k .. " id = "..v)
|
| 60 | - | term.setCursorPos(x,y) |
| 60 | + | |
| 61 | - | for i = 1,(y1-y)+1 do |
| 61 | + | print("==========================")
|
| 62 | - | for i = 1,(x1-x) do |
| 62 | + | term.setBackgroundColor(colors.red) |
| 63 | - | term.write(" ")
|
| 63 | + | print(" ")
|
| 64 | print(" ")
| |
| 65 | - | cy = cy+1 |
| 65 | + | term.setBackgroundColor(colors.blue) |
| 66 | - | term.setCursorPos(x,cy) |
| 66 | + | |
| 67 | ||
| 68 | --[[Main program]]-- | |
| 69 | - | |
| 69 | + | local valid |
| 70 | - | function reset() |
| 70 | + | print("=========================")
|
| 71 | - | term.setBackgroundColor(colors.lightGray) |
| 71 | + | print(" Skynet Systems Active ")
|
| 72 | - | term.setCursorPos(2,12) |
| 72 | + | print("=========================")
|
| 73 | - | for i = 1,size[1]-4 do |
| 73 | + | |
| 74 | - | term.write(" ")
|
| 74 | + | |
| 75 | print("=========================")
| |
| 76 | - | term.setTextColor(colors.gray) |
| 76 | + | print(" Enter Credentials... ")
|
| 77 | - | term.setBackgroundColor(colors.gray) |
| 77 | + | print("=========================")
|
| 78 | - | drawBoxPos(9,8,size[1]-1,8) |
| 78 | + | write("Username: ")
|
| 79 | - | term.setBackgroundColor(colors.lightGray) |
| 79 | + | local input_user = read() |
| 80 | - | term.setCursorPos(3,8) |
| 80 | + | write("Password: ")
|
| 81 | - | print("USER:")
|
| 81 | + | local input_pass = read("*")
|
| 82 | - | term.setBackgroundColor(colors.gray) |
| 82 | + | |
| 83 | - | drawBoxPos(9,10,size[1]-1,10) |
| 83 | + | for valid_user, valid_pass in pairs(accounts) do |
| 84 | - | term.setBackgroundColor(colors.lightGray) |
| 84 | + | if (input_user == valid_user and input_pass == valid_pass) then valid = true end |
| 85 | - | term.setCursorPos(3,10) |
| 85 | + | |
| 86 | - | print("PASS:")
|
| 86 | + | |
| 87 | if valid then | |
| 88 | - | |
| 88 | + | |
| 89 | - | function loginScreen() |
| 89 | + | print("Welcome General " ..input_user)
|
| 90 | - | term.setBackgroundColor(colors.white) |
| 90 | + | |
| 91 | findSilos() | |
| 92 | - | term.setBackgroundColor(colors.lightGray) |
| 92 | + | while true do |
| 93 | - | drawBoxPos(2,2,size[1],size[2]-1) |
| 93 | + | |
| 94 | - | term.setCursorPos(1,size[2]-7) |
| 94 | + | print("==========================")
|
| 95 | - | term.setBackgroundColor(colors.gray) |
| 95 | + | print(" [Launch Verification] ")
|
| 96 | - | drawBoxPos(((size[1]/2)-10)-1,2,((size[1]/2)+13)-1,4) |
| 96 | + | print("==========================")
|
| 97 | - | term.setBackgroundColor(colors.red) |
| 97 | + | print(" Enter Verification Code: ")
|
| 98 | - | drawBoxPos((size[1]/2)-10,1,(size[1]/2)+13,3) |
| 98 | + | print("==========================")
|
| 99 | - | term.setTextColor(colors.gray) |
| 99 | + | write("Code: ")
|
| 100 | - | str = "Skynet Mainframe" |
| 100 | + | |
| 101 | - | term.setCursorPos((size[1]/2)-(#str/2) +1,2) |
| 101 | + | |
| 102 | - | term.write(str) |
| 102 | + | |
| 103 | - | term.setBackgroundColor(colors.lightGray) |
| 103 | + | |
| 104 | - | str = "Enter Authentication Credentials" |
| 104 | + | |
| 105 | - | term.setCursorPos((size[1]/2)-(#str/2) +1,6) |
| 105 | + | |
| 106 | - | term.write(str) |
| 106 | + | |
| 107 | - | term.setBackgroundColor(colors.gray) |
| 107 | + | print("==========================")
|
| 108 | - | drawBoxPos(9,8,size[1]-1,8) |
| 108 | + | print(" Confirm launch? [Yes/No] ")
|
| 109 | - | term.setBackgroundColor(colors.lightGray) |
| 109 | + | print("==========================")
|
| 110 | - | term.setCursorPos(3,8) |
| 110 | + | write(" >")
|
| 111 | - | print("USER:")
|
| 111 | + | |
| 112 | - | term.setBackgroundColor(colors.gray) |
| 112 | + | if input == "No" then |
| 113 | - | drawBoxPos(9,10,size[1]-1,10) |
| 113 | + | |
| 114 | - | term.setBackgroundColor(colors.lightGray) |
| 114 | + | |
| 115 | - | term.setCursorPos(3,10) |
| 115 | + | |
| 116 | - | print("PASS:")
|
| 116 | + | |
| 117 | - | term.setBackgroundColor(colors.red) |
| 117 | + | |
| 118 | - | drawBoxPos(((size[1]/2)-9)-1,13,((size[1]/2)+13)-1,15) |
| 118 | + | |
| 119 | - | term.setTextColor(colors.gray) |
| 119 | + | print("==========================")
|
| 120 | - | str = "Login to Skynet!" |
| 120 | + | print(" [Target Selection] ")
|
| 121 | - | term.setCursorPos((size[1]/2)-(#str/2) +1,14) |
| 121 | + | print("==========================")
|
| 122 | - | term.write(str) |
| 122 | + | write(" Missile Count: ")
|
| 123 | - | term.setBackgroundColor(colors.lightGray) |
| 123 | + | |
| 124 | - | str = "(c) 2016 Skynet - Build. Innovate. Conquer" |
| 124 | + | |
| 125 | - | term.setCursorPos((size[1]/2)-(#str/2) +1,size[2]-2) |
| 125 | + | |
| 126 | - | term.write(str) |
| 126 | + | |
| 127 | write("Y: ")
| |
| 128 | - | evnt = {os.pullEvent()}
|
| 128 | + | |
| 129 | - | if evnt[1] == "mouse_click" then |
| 129 | + | |
| 130 | - | if evnt[3] > 8 and evnt[3] < size[1]-1 and evnt[4] == 8 then |
| 130 | + | |
| 131 | - | term.setBackgroundColor(colors.gray) |
| 131 | + | |
| 132 | - | term.setTextColor(colors.lightGray) |
| 132 | + | |
| 133 | - | term.setCursorPos(9,8) |
| 133 | + | |
| 134 | - | username = read() |
| 134 | + | print("==========================")
|
| 135 | - | elseif evnt[3] > 8 and evnt[3] < size[1]-1 and evnt[4] == 10 then |
| 135 | + | print("Target selection complete")
|
| 136 | - | term.setBackgroundColor(colors.gray) |
| 136 | + | print("==========================")
|
| 137 | - | term.setTextColor(colors.lightGray) |
| 137 | + | print(" Launching in T-Minus 10 ")
|
| 138 | - | term.setCursorPos(9,10) |
| 138 | + | sleep(1) |
| 139 | - | password = read("*")
|
| 139 | + | print(" 9 Seconds to Launch ")
|
| 140 | - | 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 |
| 140 | + | sleep(1) |
| 141 | - | if username ~= nil and password ~= nil then |
| 141 | + | print(" 8 Seconds to Launch ")
|
| 142 | - | loggedin = false |
| 142 | + | sleep(1) |
| 143 | - | for i = 1,#users do |
| 143 | + | print(" 7 Seconds to Launch ")
|
| 144 | - | if username == users[i] then |
| 144 | + | sleep(1) |
| 145 | - | if password == passwords[i] then |
| 145 | + | print(" 6 Seconds to Launch ")
|
| 146 | - | term.setTextColor(colors.lime) |
| 146 | + | sleep(1) |
| 147 | - | term.setBackgroundColor(colors.lightGray) |
| 147 | + | print(" 5 Seconds to Launch ")
|
| 148 | - | str = "Access Granted. Welcome back, "..username |
| 148 | + | sleep(1) |
| 149 | - | term.setCursorPos((size[1]/2)-(#str/2) +1,12) |
| 149 | + | print(" 4 Seconds to Launch ")
|
| 150 | - | term.write(str) |
| 150 | + | sleep(1) |
| 151 | - | loggedin = true |
| 151 | + | print(" 3 Seconds to Launch ")
|
| 152 | - | sleep(3) |
| 152 | + | sleep(1) |
| 153 | - | end |
| 153 | + | print(" 2 Seconds to Launch ")
|
| 154 | - | end |
| 154 | + | sleep(1) |
| 155 | - | end |
| 155 | + | print(" 1 Seconds to Launch ")
|
| 156 | - | if loggedin then |
| 156 | + | sleep(1) |
| 157 | print(" Do you wish to Abort [Y/N]? ")
| |
| 158 | sleep(1) | |
| 159 | write(" >")
| |
| 160 | local abort = read() | |
| 161 | if abort == "Yes" then | |
| 162 | os.reboot() | |
| 163 | elseif abort == "No" then | |
| 164 | - | red() |
| 164 | + | |
| 165 | - | write("Enter Launch Verification Code: ")
|
| 165 | + | sleep(12) |
| 166 | os.reboot() | |
| 167 | - | red() |
| 167 | + | |
| 168 | os.reboot() | |
| 169 | end | |
| 170 | end | |
| 171 | end | |
| 172 | end | |
| 173 | else print("Access Denied")
| |
| 174 | - | red() |
| 174 | + | print("Rebooting System")
|
| 175 | - | write("Launch Confirmation [Yes/No]: ")
|
| 175 | + | |
| 176 | end |