SHOW:
|
|
- or go back to the newest paste.
| 1 | --Silo Launch PC, [working] [By Andrew2060] | |
| 2 | ||
| 3 | --[[Settings]]-- | |
| 4 | local icbmSide = "back" | |
| 5 | local armed = true | |
| 6 | --set armed to false to disarm silo. | |
| 7 | ||
| 8 | --[[Init]]-- | |
| 9 | local icbm = peripheral.wrap(icbmSide) | |
| 10 | local masterID | |
| 11 | ||
| 12 | peripheral.find("modem", rednet.open)
| |
| 13 | ||
| 14 | - | term.clear() |
| 14 | + | |
| 15 | - | term.setCursorPos(1, 1) |
| 15 | + | |
| 16 | - | end |
| 16 | + | term.clear() |
| 17 | term.setCursorPos(1, 1) | |
| 18 | - | rednet.open("top")
|
| 18 | + | end |
| 19 | ||
| 20 | ||
| 21 | --[[Main program]]-- | |
| 22 | - | print("Waiting for Launch Confirmation Message")
|
| 22 | + | |
| 23 | while true do | |
| 24 | print("Waiting for Threat Message")
| |
| 25 | - | if (msg == "ping silo") then |
| 25 | + | |
| 26 | ||
| 27 | if (msg == "ABM1") then | |
| 28 | - | rednet.send(masterID, "pong") |
| 28 | + | |
| 29 | masterID = id; | |
| 30 | rednet.send(masterID, "ABM") | |
| 31 | - | print(" launch to x=" .. msg.x .. ", y=" .. msg.y .. ", z=" .. msg.z)
|
| 31 | + | |
| 32 | if type(msg.x) == "number" and type(msg.y) == "number" and type(msg.z) == "number" then | |
| 33 | print(" launching CounterMeasures At x=" .. msg.x .. ", y=" .. msg.y .. ", z=" .. msg.z)
| |
| 34 | icbm.setTarget(msg.x, msg.y, msg.z) | |
| 35 | if (armed) then | |
| 36 | peripheral.call("back","launch")
| |
| 37 | end | |
| 38 | else | |
| 39 | print(" invalid table command")
| |
| 40 | end | |
| 41 | else | |
| 42 | print(" invalid msg '", msg, "' from '", id, "', distance=", distance)
| |
| 43 | end | |
| 44 | end |