corona - Comparing integer variables in LUA -
i'm getting strange error, when trying compare 2 integer variables using lua on corona sdk.
basically have
**janswer** -- variable set via json, value can 0 or 1. local function checkanswer(answer) if (answer == janswer ) print("correct answer") print("answer = "..answer.." janswer = "..janswer) else print("wrong answer") print("answer = "..answer.." janswer = "..janswer) end end checkanswer(1) -- calling function here
heres problem, if output "answer = 1, janswer = 1", still "wrong answer".
basically, janswer, being seen string, needed convert string number, using global class on lua named tonumber()
janswer = tonumber(janswer, 10) -- convert using decimal base
thanks!
Comments
Post a Comment