Simple question, how do I turn a string value into a int value. In Python, the programming languages I'm most comfortable with, you simple write:
strvalue = "3"
toadd = 7
strvalue = int(strvalue)
total = strvalue + toadd
But how can i do this in Lua
Simple question, how do I turn a string value into a int value. In Python, the programming languages I'm most comfortable with, you simple write:
strvalue = "3"
toadd = 7
strvalue = int(strvalue)
total = strvalue + toadd
But how can i do this in Lua
int = tonumber(string)
but what if the string is "2.33" for example, that wont be an integer
Thanks
Well, if it's 2.33 he will just have to make a numberValue instead, makes no difference + he asked how to turn a string into an integer, and there is simply no way to make "2.33" an int, considering that an int can't have decimals
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
There's a built-in called "tonumber" that will convert to a number type from a string type. For example; tonumber("5") --> 5
Just grab whats in the IntValue, then delete the invalue, then put everything in the IntValue into the number value :P