Thanks for the prompt reply. I am
using lua 4.0 and it looks like there is no tag method for equal. I should
have stated I was using 4.0. The pushing of the data as a number won't
work because I am only pushing one of the two values being compared. The
second value is in the global space and will be of usertype. For new I
wrote a function called AreSame() but maybe I should add my own tag method for
equals to lua 4.0. I am guessing it wasn't done for performance
reasons.
----- Original Message -----
Sent: Monday, August 11, 2003 4:21
PM
Subject: Re: Compare by value.
push them as numbers and not as userdata?
or: check
the "__eq" metamethod (manual page 17) & set it for the
userdata.
(perhaps the latter is better - you'll use ints and not
doubles, plus it's more elegant.. ;)
Leigh McRae kirjoittaa
maanantaina, 11. elokuuta 2003, kello 23:01:
I am having trouble
getting lua to compare my own C++ types. I have a class called Handle
that is simply a 32bit int that gets mapped to a pointer (Low 16bits
for ID and high 16bit for a magic number). When I push these on the
stack to get compared, I believe they are getting compared by thier memory
location. Other than writing a function that compares two Handles, how
can I get lua to compare them as if they are numbers, which they are?/smaller>/fontfamily> Leigh
McRae Lead Programmer Rockstar Games Toronto www.rockstargames.com /color>/smaller>/fontfamily>
|