lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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?
Leigh McRae
Lead Programmer
Rockstar Games Toronto