People, I´m trying to do a very simple calculator just two variables and one is linked to the other. It means that I only need to input one number in one of two fields that will appear on screen and the other would be automatically calculated.
But I´m getting some error and I don´t know why.
The error message is: main.lua attempts to compare nil with number.
The error is pointing to line 26 on my code.
What I´m doing wrong?
Does anybody can help me?
Thanks in advance.
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here header = display.newText( "KalKHOS", 50, 5 , native.systemFontBold , 20 ) header:setFillColor(1, 0.5, 0) local KOHtxt = display.newText( "KOH (g.)", 50, 50 , native.systemFontBold , 20 ) KOHtxt:setFillColor(1, 1, 1) local KOHx = native.newTextField( 120, 90, 220, 36 ) KOHx.inputType = "number" local Sulftxt = display.newText( "S (g.)", 35, 140 , native.systemFontBold , 20 ) Sulftxt:setFillColor(1, 1, 0) local Sulfx = native.newTextField( 120, 180, 220, 36 ) Sulfx.inputType = "number" function show() local Phi = 1.6 local KOHxNumber = tonumber (KOHx.text) local SulfxNumber = tonumber (Sulfx.text) if KOHxNumber \> SulfxNumber then Sulftxt = (KOHxNumber \* Phi) print(Sulftxt.text) end end header:addEventListener("tap", show) --Result displayed when clicked on name.