lua-users home
lua-l archive

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


Hi,
 
I've got a problem passing in an Integer from C++ into the Lua program. I'm using the following
code to pass the variable in.
 
lua_pushinteger (state, iInt);
 
The issue is that the type of the parameter that comes through into the lua function always
seems to be "number". The values i'm trying to use are 32 bit hash's so the have the top bits
set most of the time.
 

function this.HandleEvent( this, id, to, param )
trace( "In HandleEvent" )
-- EVENT_ACTIVATE
if( id == 0x88D37A6C ) then
     return 3
-- EVENT_DEACTIVATE
elseif( id == 0x80AAE13F ) then
     return 2
-- UNHANDLED
else
    return id
end
end
 
The value returned is always the "id" that i sent in and that's no problem. The issue is that
neithre of the if comparisons work. I've tested out using these values and comparing the
hex version against the decimal version in an equality operator and it's compares fine.
 
I've tried on the pre built .exe the following
 
if( 2158682431 == 0x80AAE13F ) then
io.write( "Hello" )
end
 
and i've tried quierying what type each of these are such as
 
io.write( type( 0x80AAE13F  ) )
 
and they come back as numbers. So i'm a little confused as lua seems fine dealing with these
32 bit integers but when it comes to passing in my own it seems to fail the comparision operation
but then is happy to return back the same value that i pass in.
 
Thanks,
Tim.