[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Function call with number parameter becomes a string parameter inside the function
- From: Carsten Fuchs <CarstenFuchs@...>
- Date: Thu, 29 Jun 2006 11:46:44 +0200
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
print("'Key' is of type " .. type(Key) .. "\n");
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,
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!
Ca3D - Engine http://www.Ca3D-Engine.de
Carsten Fuchs http://www.Ca3D-Engine.de/c_Carsten.php