DefenseTech icon indicating copy to clipboard operation
DefenseTech copied to clipboard

Radar Range

Open Andrew2070 opened this issue 8 years ago • 6 comments

Hi

I posted a commit in a fork on the radar range in Defense/Common/Tile/TileRadar

I think it would be fair to change the max detection range from

500 blocks to about 5000 blocks?

This would allow for servers to build CC programs implementing MAD. Mutually Assured Destruction, by knowing the origin of a missile. Thus allowing for someone to shoot down incoming missiles, and retaliate.

Andrew2070 avatar Jun 23 '16 03:06 Andrew2070

Maybe add more CC support such as my previous Issue, as well as a satellite? I mean if that is implemented in Mekanism it could be used for a lot. Particularly those lasers and bouncing Computercraft wireless communications.

Andrew2070 avatar Jun 23 '16 20:06 Andrew2070

it would be cool if we could change alt he missile launcher only using computer craft. Is it possible to allow the launcher to be directly connected to the network using a rednet port

henri2h avatar Jun 24 '16 13:06 henri2h

Wired connections I have not tested. So far I place a computers infront of the panel and wrap them to it.

icbm.setTarget and Icbm.launch()

I have a rednet server that takes care of defense wirelessly. Uses a table of silo clients that ping the server, and the server pings them. Then when required, it collectively fires all of them in a sequence.

Andrew2070 avatar Jun 26 '16 05:06 Andrew2070

I have done that but I didn't understand why it doesn't work When I use icbm.setTarget, it didn(t update the current target so I have to do it manualy

I use this code to control the launcher :

-- login user
userName = ""
userPassword = ""

computerS = 6

-- to add :
--      - security : check if it's the right computer
--       - encrypt communication : not now
--      - rewrite how the commands are send and recieved (maybe make funtions to use less code)


-- functions


function inputClear (messageClear)
    rednet.send(computerS,"#read")
    rednet.send(computerS, "@clear")
    rednet.send(computerS, messageClear)
    return receive()
end

function inputCode (messageCode)
    rednet.send(computerS,"#read")
    rednet.send(computerS, "@code")
    rednet.send(computerS, messageCode)
    return receive()
end

function send (messageSend)
    rednet.send(computerS, messageSend)
end

function receive ()
id, messagerec = rednet.receive()
    if id == computerS then
        return messagerec
    else
        print("invalid computer")
        write("message : ")
        print(messagerec)
        return nil
    end

end


-- missile

function checkMissile ()
    send("checing state ....")
    getMissile = launch.getMissile()
    active = launch.canLaunch()
    if getMissile and active then
        print("can launch")
        send("can launch")
    else
    write("get missile : ")
    print(getMissile)

    write("can launch : ")
    print(canLaunch)

    end
    send("")
end

function setCoordinates ()
    send("Enter coordinates")
    x = inputClear("X : ")
    y = inputClear("Y : ")
    z = inputClear("Z : ")

    launch.setTarget(x, y, z)
end

function getCoordinates ()
    x,y,z = launch.getTarget()
    send("Target : x: " .. x .. " y: " .. y .. " z: " .. z)
end



-- initiating peripherals

rednet.open("right")
launch = peripheral.wrap("left")

print("starting ...")
-- starting
condition = true
while condition == true do
    print("waiting for login")
    message = receive()
    print("done")

    if message == "#login" then
        condition = false
        print("login : ok")
        send("login : ok")
    else
        print("bad startup")
        send("#error")
        os.reboot()
        condition = false
    end

end

-- stating login

print("connection accepted")

-- authentification
send("Please enter credentials : ")
-- user name
username = inputClear("User name : ")
-- password
password = inputCode("password : ")

accept = false
if username == userName then
    if password == userPassword then
        accept = true
        print("control token")
    end
end

if accept == true then
    send("Connection : ok")
else
    send("Connection : failed")
end

send( "")
print("connected")
-- state
checkMissile()

getMissile = launch.getMissile()
getMissile = true
if getMissile == true then
    send("A missile is ready to be launched")   
    print("missile : ok")

x,y,z = launch.getTarget()
send("Target : x: " .. x .. " y: " .. y .. " z: " .. z)


-- reading results
setCoordinates()
getCoordinates()




    -- add security : must verify that's it is the good computer (may use a share pasword to encrypt orders)
    while true do
message = inputClear("Launch : ")
        if message == "check" then
        checkMissile()

        elseif message == setcoords then
            setCoordinates()

        elseif message == getcoords then
            getCoordinates()

        elseif message == check then
            checkMissile()

        elseif message == "#fire" then
            getMissile = launch.getMissile()
            active = launch.canLaunch()
            if active == true then
                launch.launch()
                print("fired")
                send("fired")
                os.sleep(2)
                checkMissile()
            else
                send("error : can't launch")
                print("error : can't launch")
            end

        elseif message == "help" then
            send("help : ")
            send("help : get help (schow this page")
            send("check : retunr state of the launcher")
            send("setcoords : set the target coordinates")
            send("getcoords : get the current target cooridnates")
            send("#fire : fire the missile")

        end
        send("")
    end

else
    send("there is no missile")
    send("Station can't launch")
    send("Aborting ...")
end


-- ending communication
send("stoping ...")
send("good bye")
send("#end")
rednet.close()
os.reboot()

-- launch
-- getTarget
-- settarget
-- canLaunch
-- getMissile

and for the user terminal :

launchComputer = 5


-- functions

function send (messageSend) 
rednet.send(launchComputer, messageSend)
end

function receive()
id, messagerec = rednet.receive()
if id == launchComputer then
return messagerec
else
print("invalid computer")
return nil
end

end



-- program

rednet.open("back")

print("starting ...")
--login
print("sending login request")
send("#login")
print("recieve response")
message = receive()
print(message)

recieve = ""
while recieve ~= "#end" do
    message = receive()
    if message == "#read" then

        methods = receive()

if methods == "@clear" then
            message = receive()
            write(message)
            input = read()
            send(input)

elseif methods == "@code" then
            message = receive()
            write(message)
            input = read("*")
            send(input)

else
            message = receive()
            print(message)
            input = read()
            send(input)
        end


        else
        print(message)
        end
    end


henri2h avatar Jun 26 '16 20:06 henri2h

ok, I have reinstalled the mod and now, I can control the launcher but when I launch a missile, it exploded in the air and the server thrown an error :

[13:33:54] [Server thread/ERROR] [FML]: The mod DefenseTech attempted to force load a chunk with an invalid ticket. This is not permitted.

henri2h avatar Jun 28 '16 11:06 henri2h

Weird.

I never got that error before, Btw your code is overcomplicated, I did all that with 2 tables... I also have a system to shoot down missiles as soon as they are in 500 block range.

Andrew2070 avatar Jun 30 '16 04:06 Andrew2070