I don't understand why this happens.
function findVar() local i = string.find(equation, "%a") var = string.sub(equation, i, i) while true do i = string.find(equation, "%a", i + 1) if i == nil then break end check = string.sub(equation, i, i) if not var == check then quit("Error. Multiple variables.", true) end end end
This code is supposed to find the variable in an equation, which it does, but then it needs to find a variable that isn't the same as the 1st variable. If found, it should terminate the script. The problem is, that when it does find a variable that differs the 1st one, it doesn't terminate anything.
I have tried changing the check variable to global.
Like InSync stated,
== is consistently returning false when comparing
not var with
~= would be more suitable ie
var ~= check.
not (var == check) could work too.