aidancbrady / DefenseTech

Missiles and high-tech explosives: Calclavia's work continued.
22 stars 11 forks source link

[Question] ComputerCraft Methods #28

Open Andrew2070 opened 8 years ago

Andrew2070 commented 8 years ago

Hey,

First of all i would like to say that i greatly appreciate the ICBM updates to 1.7.10. Secondly i want to compliment you for the hard work you put into Mekanism/ICBM. However I have a few questions i would like to ask regarding CC methods and ICBM.

  1. Is it possible for a radar to output the name of a missile to a computer?
  2. IF it is possible what is the method for it, i cannot find it in game.
  3. IF it is not possible, could this be implemented in a later version?

Basically i built a ABM program to shoot down missiles. I was hoping if i could give it priority targets via knowing the name. By giving each missile a rank, and the missiles shoot down the highest rank ie nukes first.

Thanks in advance!

CaptainMegavolt commented 8 years ago

I would be interested to know this as well! Also, since radars track most entities in thier area of detection, would it be possible to have the radar output a list of entities, with names, x, y, and z coordinates, and type (I.e. player, missile, minecart, etc.)

Andrew2070 commented 8 years ago

Yeah see the issue is that my program used to shoot down missiles and track them, makes a giant log of data rather than continously update a single line. Where i can not distinguish between multiple missiles at once.

It basically labels the missiles in order of detection, which can be random. The missiles are labeled locally as threat numbers from 0-infinity.

I was hoping if this could be implemented it would do the following,

  1. Allow for prioritization of anti-ballistic missile systems.
  2. Allow for easier table storing of coordinates/missile info.
Andrew2070 commented 8 years ago

Also is it possible to find means to UP the radius of a radar, as well as another method which allows us to change the coordinates of a missiles destination mid flight? allowing for missiles to actually home onto entities.

Andrew2070 commented 8 years ago

Could this be checked out @aidancbrady

Andrew2070 commented 8 years ago

Bump

Andrew2070 commented 8 years ago

Bump

bu1th4nh commented 8 years ago

Can you put it to Pastebin?

Andrew2070 commented 8 years ago

`--[[Skynet Nuclear ABM Defense Program by Andrew2060]]-- --[ABM Server, use with http://pastebin.com/aNsduCem]]-- --[System requires atleast 5 CC's with Modems and ABMs]]-- --[System has 5% chance of failure in killing missiles]]--

--[[Settings]]-- local waitDelay = 2 local countersPerMissile = 1 local missileDelay = 3

--[[Initialization]]-- local silos, curSilo = {}, 1 peripheral.find("modem", rednet.open) term.setBackgroundColor(colors.blue)

local function red() term.setBackgroundColor(colors.red) print(" ") term.setBackgroundColor(colors.blue) end

rednet.broadcast("ABM1")

repeat local id, msg = rednet.receive(waitDelay) if msg == "ABM" then table.insert(silos, id) end until not id

--[[Main Programs]]-- while true do if not redstone.getInput("back") then term.clear() term.setCursorPos(1, 1)

    red()
    print("        SKYNET DEFENSE SYSTEMS ACTIVATED           ")
    red()
    print("      ANTI-BALLISTIC MISSILE SHIELD ONLINE         ")
    red()
    red()
    print("               [STANDBY ABM Silos]                 ")

    for k, v in ipairs(silos) do print("  silo #" .. k .. " id = "..v) end
    red()

    repeat os.pullEvent("redstone") until redstone.getInput("back")
end

term.clear()
term.setCursorPos(1, 1)
term.setTextColor(colors.red)

print("Incoming Missiles:")
print("Firing CounterMeasures\n")

maptab = peripheral.call("back","getEntities") maptxt = textutils.serialize(maptab) if maptxt ~= "{}" then allDat = 0 for num in pairs(maptab) do allDat = allDat+1 end targets = allDat/3 for i=0,targets-1 do local msg = {["x"] = math.floor(maptab["x"..i]), ["y"] = math.floor(maptab["y"..i]), ["z"] = math.floor(maptab["z_"..i])}

    print("Incoming Missile Threat #" .. i .. " at X:" .. msg.x .. " Y:" .. msg.y .. " Z:" .. msg.z)
    print("Launching " .. countersPerMissile .. " ABM Missile CounterMeasures...\n")

    for i = 1, countersPerMissile do
        rednet.send(silos[curSilo], msg)
        curSilo = (curSilo == #silos) and 1 or (curSilo + 1)
        sleep(missileDelay)
        end
    sleep(0)
    end
 sleep(0)
end

sleep(2) end sleep(1)

--Silo Launch PC, [working] [By Andrew2060] _Another program

--[[Settings]]-- local icbmSide = "back" local armed = true --set armed to false to disarm silo.

--[[Init]]-- local icbm = peripheral.wrap(icbmSide) local masterID

peripheral.find("modem", rednet.open)

--[[Functions]]-- local function clear() term.clear() term.setCursorPos(1, 1) end

--[[Main program]]-- clear() while true do print("Waiting for Threat Message") id, msg, distance = rednet.receive(masterID)

if (msg == "ABM1") then print(" master=", id) masterID = id; rednet.send(masterID, "ABM") elseif type(msg) == "table" and id == masterID then if type(msg.x) == "number" and type(msg.y) == "number" and type(msg.z) == "number" then print(" launching CounterMeasures At x=" .. msg.x .. ", y=" .. msg.y .. ", z=" .. msg.z) icbm.setTarget(msg.x, msg.y, msg.z) if (armed) then peripheral.call("back","launch") end else print(" invalid table command") end else print(" invalid msg '", msg, "' from '", id, "', distance=", distance) end end `