Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- local silos = {}
- local selected = 1
- print("Detecting silos...")
- for i,v in ipairs(rs.getSides()) do
- if peripheral.getType(v) == "ICBMLauncher" then
- print("Silo found on side:"..v)
- table.insert(silos, {v, peripheral.wrap(v)})
- end
- end
- if #silos == 0 then
- print("No silos detected.")
- print("Please place a launcher control panel next to the computer.")
- os.sleep(2)
- return
- elseif #silos == 1 then
- print("Found 1 silo.")
- else
- print("Found "..#silos.." silos.")
- end
- os.sleep(0.75)
- local function getPW()
- if fs.exists("launchCode") then
- term.clear()
- term.setCursorPos(5, 8)
- write("Please enter a launch code.")
- local handle = fs.open("launchCode", "r")
- local code = handle.readAll()
- handle.close()
- local userPW = read()
- term.clear()
- term.setCursorPos(1,1)
- return (code == userPW)
- else
- return true
- end
- end
- local function printColored(...)
- for i=1, arg["n"] do
- if type(arg[i]) == "string" then
- write(arg[i])
- elseif type(arg[i]) == "number" then
- if term.isColor() then
- term.setTextColor(arg[i])
- end
- end
- end
- print("")
- term.setTextColor(colors.white)
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- printColored(colors.white, "Silo ", colors.lime, tostring(selected), colors.white, " selected.")
- print("")
- print("Details: ")
- print("")
- printColored("Frequency: ", colors.lime, tostring(silos[selected][2].getFrequency()))
- local targetX, targetY, targetZ = silos[selected][2].getTarget()
- print("Targeted: ")
- printColored("X: ", colors.lime, tostring(targetX))
- printColored("Y: ", colors.lime, tostring(targetY))
- printColored("Z: ", colors.lime, tostring(targetZ))
- print("")
- print("Options: ")
- printColored("1. ", colors.lime, "Select Silo")
- printColored("2. ", colors.orange, "Set Silo Target")
- printColored("3. ", colors.orange, "Set Silo Frequency")
- printColored("4. ", colors.red, "Launch")
- printColored("5. ", colors.red, "Launch All")
- printColored("6. ", colors.orange, "Set All Silo Frequencies")
- printColored("7. ", colors.orange, "Set All Silo Targets")
- local event, key = os.pullEvent("key")
- if key == 2 then
- term.clear()
- term.setCursorPos(1,1)
- print("Detected silos:")
- for i,v in ipairs(silos) do
- print(i..". Silo on: "..v[1].." side")
- end
- while true do
- local event, key = os.pullEvent("key")
- if key >= 2 and key <=7 then
- if silos[key-1] then
- selected = key-1
- break
- end
- end
- end
- elseif key == 3 then
- local x, y, z = 0
- while true do
- term.setCursorPos(1,7)
- term.clearLine()
- write("X: ")
- local selX = read()
- if tonumber(selX) then
- x = tonumber(selX)
- break
- end
- end
- while true do
- term.setCursorPos(1,8)
- term.clearLine()
- write("Y: ")
- local selY = read()
- if tonumber(selY) then
- y = tonumber(selY)
- break
- end
- end
- while true do
- term.setCursorPos(1,9)
- term.clearLine()
- write("Z: ")
- local selZ = read()
- if tonumber(selZ) then
- z = tonumber(selZ)
- break
- end
- end
- silos[selected][2].setTarget(x,y,z)
- elseif key == 4 then
- while true do
- term.setCursorPos(1,5)
- term.clearLine()
- write("Frequency: ")
- local selFreq = read()
- if tonumber(selFreq) then
- silos[selected][2].setFrequency(tonumber(selFreq))
- break
- end
- end
- elseif key == 5 then
- if getPW() then
- for i=10, 1, -1 do
- term.clear()
- term.setCursorPos(12,9)
- write("Launching in: "..i.." seconds...")
- os.sleep(1)
- end
- silos[selected][2].launch()
- else
- term.clear()
- term.setCursorPos(12,9)
- print("Incorrect code!")
- os.sleep(2)
- end
- elseif key == 6 then
- if getPW() then
- for i=10, 1, -1 do
- term.clear()
- term.setCursorPos(12,9)
- write("Launching in: "..i.." seconds...")
- os.sleep(1)
- end
- for i,v in ipairs(silos) do
- v[2].launch()
- os.sleep(3)
- end
- else
- term.clear()
- term.setCursorPos(12,9)
- print("Incorrect code!")
- os.sleep(2)
- end
- elseif key == 7 then
- while true do
- term.setCursorPos(1,5)
- term.clearLine()
- write("Frequency: ")
- local selFreq = read()
- if tonumber(selFreq) then
- for i,v in ipairs(silos) do
- v[2].setFrequency(tonumber(selFreq))
- end
- break
- end
- end
- elseif key == 8 then
- local x, y, z = 0
- while true do
- term.setCursorPos(1,7)
- term.clearLine()
- write("X: ")
- local selX = read()
- if tonumber(selX) then
- x = tonumber(selX)
- break
- end
- end
- while true do
- term.setCursorPos(1,8)
- term.clearLine()
- write("Y: ")
- local selY = read()
- if tonumber(selY) then
- y = tonumber(selY)
- break
- end
- end
- while true do
- term.setCursorPos(1,9)
- term.clearLine()
- write("Z: ")
- local selZ = read()
- if tonumber(selZ) then
- z = tonumber(selZ)
- break
- end
- end
- for i,v in ipairs(silos) do
- v[2].setTarget(x,y,z)
- end
- end
- end
- os.pullEvent = oldPull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement