Posted 06 January 2013 - 03:19 AM
I'm trying to get == to return true when a user inputed value is compared to the "i" variable in a for loop.
I've made a test program here http://pastebin.com/snB9iNsz that correctly compares "i" and "torches" with == like it should outputing this.
1 3
2 3
3 3
this actually prints!
4 6
5 6
6 6
this actually prints!
7 9
8 9
9 9
this actually prints!
10 12
However, when I have the program http://pastebin.com/630F7vei ask the user for the value of "torches" the == doesn't reconize "i" and "torches" as being the same number.
1 3
2 3
3 3
4 3
5 3
6 3
7 3
8 3
9 3
10 3
I'm just now starting to learn lua but have some c++ experience. I noticed that in lua you don't have to declare the variable type like you do when creating variables in c++. That has lead me to believe that the issue is lua not assigning the inputed variable as an int but as a char and that is why == is not thinking 3 and 3 are the same.
Now that I said that I guess my "real" question would be is it possible to declare the type of a variable in lua? and if not is there a work around possible that will achieve the result I'm looking for?
Thanks for the help!
I've made a test program here http://pastebin.com/snB9iNsz that correctly compares "i" and "torches" with == like it should outputing this.
1 3
2 3
3 3
this actually prints!
4 6
5 6
6 6
this actually prints!
7 9
8 9
9 9
this actually prints!
10 12
However, when I have the program http://pastebin.com/630F7vei ask the user for the value of "torches" the == doesn't reconize "i" and "torches" as being the same number.
1 3
2 3
3 3
4 3
5 3
6 3
7 3
8 3
9 3
10 3
I'm just now starting to learn lua but have some c++ experience. I noticed that in lua you don't have to declare the variable type like you do when creating variables in c++. That has lead me to believe that the issue is lua not assigning the inputed variable as an int but as a char and that is why == is not thinking 3 and 3 are the same.
Now that I said that I guess my "real" question would be is it possible to declare the type of a variable in lua? and if not is there a work around possible that will achieve the result I'm looking for?
Thanks for the help!