lua-users home
lua-l archive

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


Hello all,

I'm calling a Lua function from C++ code as described in the PiL1/2 book chapter 25.2, see http://www.lua.org/pil/25.2.html .

The parameters for the function are pushed onto the stack as numbers, using lua_pushinteger() and/or lua_pushnumber().

However, the called Lua function

function f(Key)
    print("'Key' is of type " .. type(Key) .. "\n");
end

outputs:   'Key' is of type string


Strangely, the value of Key is the correct string representation of the number that I pushed onto the stack in the C++ code earlier, e.g. if I called lua_pushinteger(L, 48); then in the Lua function f above, Key=="48".

That is, in f I expected that Key==48, but find that Key=="48".
(And therefore my equality tests like Key==48 always fail.)


--> I'm unable to get a clue on what's going on. Am I missing something? Any suggestions/hints/help/etc. are mostly appreciated!

Thank you very much!

Best,
Carsten



--
Ca3D - Engine    http://www.Ca3D-Engine.de
Carsten Fuchs    http://www.Ca3D-Engine.de/c_Carsten.php