Jump to content




rednet


2 replies to this topic

#1 joseph1999205

  • New Members
  • 2 posts

Posted 05 June 2017 - 10: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

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 05 June 2017 - 11:22 PM

read() returns strings, not numbers. If the string represents a number then you can convert it with tonumber():

sid = tonumber( read() )


#3 joseph1999205

  • New Members
  • 2 posts

Posted 06 June 2017 - 01:40 PM

thank you so much !
that solved it





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users