--# server/master/controller --[[Functions]]-- local silo = {} local curSilo = 1 local function printSilos() if silo[1] then textutils.pagedTabulate({"ID", "Type", "Armed"}, unpack(silo)) else print("No connected slaves") end end local function findSilos() rednet.broadcast("ping silo") local timerID = os.startTimer(waitDelay) while true do local message = {rednet.receive()} if event == "rednet_message" and msg == "pong" then silo[#silo+1] = message[2] timerID = os.startTimer(waitDelay) elseif event == "timer" and id == timerID then return end end end local function setTargets() local count, x, y, z while not (type(count) == "number" and type(x) == "number" and type(y) == "number" and type(z) == "number") do red() print(" [Target Selection] ") red() term.setBackgroundColor(colors.blue) write(" Missile Count: ") count = tonumber(read()) print("Coordinates:") write("X: ") x = tonumber(read()) write("Y: ") y = tonumber(read()) write("Z: ") z = tonumber(read()) sleep(1) end end local function launch(count, x, y, z) local msg = {x = x, y = y, z = z} print("launching Missiles At " .. x .. ", " .. y .. ", " .. z) for i = 1, count do rednet.send(silo[curSilo], msg) curSilo = (curSilo == #silo) and 1 or (curSilo + 1) sleep(5) end end local function fire(ID) if silo[ID][3] then print("Target Selection Complete:") term.setBackgroundColor(colors.blue) print("Launching at: "..x..","..y..","..z) print("Launching Missiles -T Minus 10 Seconds.") sleep(1) sleep(1) write(" Abort [Yes/No]: ") local abort = read() if abort == "Yes" then disarm(#silo) write("Warheads Disarmed Successfully") sleep(1) write("Session Expired, renewing login:") sleep(2) os.reboot() elseif abort == "No" then end launch(count, x, y, z) sleep(10) os.reboot() end rednet.send(silo[ID][1]) else print("Silo not armed, can't fire while not armed") end end local function arm(ID) silo[ID][3] = "true" rednet.send(silo[ID][1],"arm") end ` local function disarm(ID) silo[ID][3] = "false" rednet.send(silo[ID][1],"disarm") end findSilos() printSilos()