So, I have a simple snippet of code among much more code...
Code: Select all
if (newx > self.x) or (newx < self.x) then
player.xvel = 0
end
and when I run it, I get this error...
Code: Select all
Error
player.lua:18 attempt to compare number to boolean
Alright, seems rather straightforward. But then I try...
or...
or...
to force the program to terminate and display the variables' values. And, unexpectedly, it ALWAYS returns a numeral value for each variable. So the problem is apparently isolated to the region of code I've shared with you, which is why I didn't bother to post the complete script for my game. Anyway, after staring at my laptop screen for about half an hour, I decided to try this...
Code: Select all
error((newx > self.x) or (newx < self.x))
and what do I get?...
So there is nothing wrong with the condition statement itself. I've looked around the region where the problem is occurring, and I see nothing wrong with it. There's apparently no problem with stray parenthesis, operators, end's, etc. because I can easily insert an error function directly before the if statement. All I can figure is that it may be some problem with metatables. Just shoot me with ideas, I'll try anything if you think it's worth a try.
Notes/Synopsis: This snippet of code is located in a function. newx is a variable local to the function. self is the address of a table. All variables seem to work fine until I attempt to use them in an if statement.