Pretty simple. I'm putting in tonumber(x), the program goes through, then when I come to the main while loop of my program, which is locationX < x, it says something along the lines of "attempt to compare number to string; got string", something like that. For reference, locationX was a variable that I initially declared as a number and x is a variable that was entered by the user and is supposed to be converted to a string from a number.
tonumber() not working
Started by Copilot, Jun 22 2013 08:52 PM
3 replies to this topic
#1
Posted 22 June 2013 - 08:52 PM
#2
Posted 23 June 2013 - 07:50 PM
Split into new topic.
Please post your whole code and the full text of any error messages you are receiving.
Please post your whole code and the full text of any error messages you are receiving.
#3
Posted 24 June 2013 - 11:20 AM
Are you using
The tonumber function will return the value converted to a number (or nil if it can't be converted). So, you have to store that return value somewhere.
x = tonumber(x)or just
tonumber(x)
The tonumber function will return the value converted to a number (or nil if it can't be converted). So, you have to store that return value somewhere.
#4
Posted 24 June 2013 - 10:03 PM
Aaaaaaaaaaaahh. Thank you very much, Malzahar
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











