Posted 29 August 2012 - 12:06 AM
Hello, I am trying to make a turtle to go a specified amount of blocks forward, and the amount being specified by a computer via a rednet.send() function. In my efforts I have striped the code down to a simple form.
computer:
rednet.open("right")
function mine()
print("I want my turtle to go this many blocks..")
rednet.send( 13 , io.read() )
mine()
end
mine()
turtle:
rednet.open("right")
id,message = rednet.receive()
print(message)
if message<10 then
print("good")
end
As you can see the computer gets an input via the player to the turtle, for testing purposes I have been using 5. The turtle then gets that input and compares it to the number 10, so if the input is less than 10, the turtle will print "good". However when tested I get the following error: "mine:4: attempt to compare __lt on nil and number" I assume that this is because the computer sees the input as text and not a number. So how can I get this to work? Thank you for help in advance, I hope this hasn't already been answered, I did do my best to find a answer before asking.
~firenight
computer:
rednet.open("right")
function mine()
print("I want my turtle to go this many blocks..")
rednet.send( 13 , io.read() )
mine()
end
mine()
turtle:
rednet.open("right")
id,message = rednet.receive()
print(message)
if message<10 then
print("good")
end
As you can see the computer gets an input via the player to the turtle, for testing purposes I have been using 5. The turtle then gets that input and compares it to the number 10, so if the input is less than 10, the turtle will print "good". However when tested I get the following error: "mine:4: attempt to compare __lt on nil and number" I assume that this is because the computer sees the input as text and not a number. So how can I get this to work? Thank you for help in advance, I hope this hasn't already been answered, I did do my best to find a answer before asking.
~firenight