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

Wireless tonumber() help

Started by Aceofrogues, 09 December 2012 - 05:25 AM
Aceofrogues #1
Posted 09 December 2012 - 06:25 AM
I am trying to make a program, that sends wireless commands to a turtle. The idea is that he moves MoveX forward turn right and move moveY forward, but i havent gotten to that part yet, because i have an issue.
My turtle received the commands( the moveX and moveY) but is receiving them as moveX and moveY and not 8 and 9.
I put some tonumber() in there, but i suspect i may not be using them correctly and that is the problem.

Computor:

term.clear()
term.setCursorPos(1, 1)
rednet.open("top")
moveX = 9
moveY = 8
tonumber (moveX)
tonumber (moveY)
rednet.send(3, "place")
print("Message send")
id, message  = rednet.receive()
print(message)
rednet.broadcast("moveX")
rednet.broadcast("MoveY")
print("Message send")

turtle:

term.clear()
term.setCursorPos(1, 1)
print("Waiting for message")
rednet.open("right")
id, message  = rednet.receive()
print(message)
moveX = message
id, message  = rednet.receive()
print(message)
moveY = message
print("Message received")

Hope i put them in spoiler tags…
Dlcruz129 #2
Posted 09 December 2012 - 06:35 AM
Remove the "s around movex and movey when you broadcast. You don't need tonumber() you need tostring(). You're trying to turn the numbers into pieces of text, called strings.

This is what you should do:
rednet.broadcast(tostring(movex))
rednet.broadcast(tostring(movey))
Aceofrogues #3
Posted 09 December 2012 - 06:50 AM
It is now working perfectly! I have been going at it for the last hour, so this is awesome. + internetz for you sir

(do i have to edit the topic title to say solved, and if yes then how do i do that?)
Dlcruz129 #4
Posted 09 December 2012 - 07:07 AM
It is now working perfectly! I have been going at it for the last hour, so this is awesome. + internetz for you sir

(do i have to edit the topic title to say solved, and if yes then how do i do that?)

No, please leave the post up so others may learn from it.