Sorry, tfoote what you gave me still does the same thing. I'm not to sure what you're trying to say sorry MysticT? If you could give me a fixed version of my code I could probably learn from it. I also have another question, no sense in creating another thread.
So, I have this program which sends messages to a turtle, which acts accordingly, the turtle part of the code is going fine but the client end (from the computer) is having problems. Rednet :347: positive umber expected.
Here is the code:
rednet.open("right")
term.clear()
term.setCursorPos(1,1)
print ("Which turtle would you like to send commands to?")
r = io.read()
while true do
term.clear()
term.setCursorPos(1,1)
print ("Turtlecom wireless (client) v1.4 Running.")
print ("Type 'help' for help or 'exit' to exit.")
x = io.read()
if x == "help" then
term.clear()
term.setCursorPos(1,1)
print ("This program sends commands to the previously designated turtle. Typing 'exit' will cause both the client and turtle to close the program. Commands are as follows:")
print ("w = forward")
print ("s = back")
print ("a = turn left")
print ("d = turn right")
print ("q = up")
print ("z = down")
print ("r = place up")
print ("f = place")
print ("v = place down")
print ("Will return to interface in 10 seconds")
sleep(10)
elseif x == "exit" then
rednet.send(r, "exit")
break
elseif x == "w" then
rednet.send(r, "w")
elseif x == "s" then
rednet.send(r, "s")
elseif x == "a" then
rednet.send(r, "a")
elseif x == "d" then
rednet.send(r, "d")
elseif x == "q" then
rednet.send(r, "q")
elseif x == "r" then
rednet.send(r, "r")
elseif x == "f" then
rednet.send(r, "f")
elseif x == "v" then
rednet.send(r, "v")
else
print ("That is not a valid commans")
sleep(1)
end
end
I'm pretty sure I know why, but I'm not sure how to fix it? io.read() returns a string right? Therefore 'r' is a string and rednet won't accept a string as the receiver id. But I'm not sure how to get use input without the output being a string, rather than number. Is there a specific function? I don't need a rewrite of my code just the name of the function (unless of course that isn't the problem). Thanks in advance!