This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
joseph1999205's profile picture

rednet

Started by joseph1999205, 05 June 2017 - 09:50 PM
joseph1999205 #1
Posted 05 June 2017 - 11:50 PM
im trying to send a packet via rednet , but i want the computer to ask me which ID i want to send before sending to this ID
so i created a read variable

variable = read()

rednet.send(variable, "message")
but i get an error saying : " rednet:87 expected number"





rednet.open("top")

print("Choose ID Range To Scan: ")

range = read()

term.clear()

term.setCursorPos(1,1)

for i = 0,range do


rednet.send(i, "check")


id, message = rednet.receive(1)


if message == "ready" then

term.setTextColor(colors.green)

print(" ID:".. id.. " Active")


term.setTextColor(colors.white)


else


term.setTextColor(colors.red)

print(" ID:"..i.."Nothing Found")

term.setTextColor(colors.white)



end


end



print("================")

write("Choose Session ID:")

sid = read()

write("Attempting Private Connection with "..sid)

write(".")

sleep(0.5)

write(".")

sleep(0.5)

write(".")

rednet.send(sid, "go") – HERE I GET THE ERROR
Bomb Bloke #2
Posted 06 June 2017 - 12:22 AM
read() returns strings, not numbers. If the string represents a number then you can convert it with tonumber():

sid = tonumber( read() )
joseph1999205 #3
Posted 06 June 2017 - 02:40 PM
thank you so much !
that solved it