CC;Tweaked, modems not seeing eachother.

Started by ilov3gam3z, Feb 12, 2025, 07:36 PM

Previous topic - Next topic

ilov3gam3z

I have a pocket pc which is wireless and a pc that has a wireless modem attached to it. I also have another pc with a modem which is my home/base pc. I am trying to send a signal from the pocket pc to the base pc with an intermediate "dns" server computer. I have not worked out the code to actualy make them, you know, communicate but i have worked out the code to make the pocket pc interact with the dns server. The problem is though, every time i run focus.lua (pocket pc) and try to interact with mccdServer.lua (dns server) it always says MCCD Query Server not found. Here is mccdServer.lua and focus.lua I am running this in atm9-tts 1.20.1
MCCDSERVER
local modem = peripheral.find("modem") or error("No modem found", 0)
local function host(host_name, mccp, modifier_seed)
    term.clear()
    math.randomseed(modifier_seed)
    decrypted_key = math.randomseed(modifier_seed)
    local channel = math.random(1, 65535)
    modem.open(channel)
    textutils.slowPrint("Hosted " .. host_name .. " on channel " .. channel)
    return decrypted_key, channel, mccp
end
host("mccdQueryServer", 90911, 79174)
hosts = {
    basepc = 21606,
    focus = 52477
}
while true do
    local mccdQueryListener, side, channel, reply_channel, message, distance = os.pullEvent("modem_message")
    if modem.isOpen(hosts[message]) then
        modem.transmit(reply_channel, channel, "MCCD Query Response: True")
        local mccdIdListener, side2, channel2, reply_channel2, message2, distance2 = os.pullEvent("modem_message")
        if message == "Modifier_Seed?" then
            modem.transmit(reply_channel, channel, hosts[message])
        end
    else
        modem.transmit(reply_channel, channel, "MCCD Query Response: False")
    end
end
FOCUS
local modem = peripheral.find("modem") or error("No modem found", 0)
local function host(host_name, mccp, modifier_seed)
    term.clear()
    decrypted_key = math.randomseed(modifier_seed)
    local channel = math.random(1, 65535)
    modem.open(channel)
    textutils.slowPrint("Hosted " .. host_name .. " on channel " .. channel)
    return decrypted_key, channel, mccp
end
local function findHost(host_name, private_channel)
    local hosts = {
        mccdQueryServer = 10469
    }
    if modem.isOpen(hosts["mccdQueryServer"]) then
        textutils.slowPrint("MCCD Query Server found, sending query")
        modem.transmit(hosts["mccdQueryServer"], private_channel, "basepc")
        local event, side, channel, replyChannel, message, distance
        repeat
            event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
        until channel == private_channel
        if message == "MCCD Query Response: True" then
            textutils.slowPrint("MCCD Query Response: True")
            modem.transmit(hosts["mccdQueryServer"], private_channel, "Modifier_Seed?")
        else
            return error("MCCD Query Response: False", 0)
        end
    else
        return error("MCCD Query Server not found", 0)
    end
end
host("focus", 4444, 13686)
textutils.slowPrint("Enter host name: ")
local host_name = read()
findHost(host_name, channel)
(also the indentation may have not formatted right, sorry.)

ilov3gam3z

also sorry if its bad code i main python and have no idea how to lua so alot of it is copy pasted ngl