Posted 11 May 2017 - 02:21 PM
Hi,
I want to be able to attach a rednet moden during the runtime of a program and use it. However, when I try to do so I get the following error:
My code is below:
If I start the program with no modem attached, it prints correctly. If I afterwards attach a modem without ending the program, it gives the error mentioned above.
If I start the program with the modem attached already it all works fine and prints sucessfully connected.
Is there any way around this or do I have to restart the program after the modem is connected?
I want to be able to attach a rednet moden during the runtime of a program and use it. However, when I try to do so I get the following error:
peripheral:9: No such method getNamesRemote
My code is below:
local printed1 = false
local printed2 = false
while true do
if not pcall(rednet.open, "top") then
if not printed1 then
printed1 = true
term.clear()
term.setCursorPos(1, 1)
print("There is no modem attached to the top of this computer!")
end
else
local serverID = rednet.lookup("protocol", "hostname")
if not serverID then
if not printed2 then
printed2 = true
term.clear()
term.setCursorPos(1, 1)
print("Unable to contact the server")
end
else
term.clear()
term.setCursorPos(1, 1)
print("Sucessfully connected")
break
end
end
end
If I start the program with no modem attached, it prints correctly. If I afterwards attach a modem without ending the program, it gives the error mentioned above.
If I start the program with the modem attached already it all works fine and prints sucessfully connected.
Is there any way around this or do I have to restart the program after the modem is connected?
Edited on 11 May 2017 - 12:23 PM