lua-users home
lua-l archive

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


Hello again,

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

Argh, sorry for the confusion, I found the answer to my question at http://www.lua.org/manual/5.1/manual.html#lua_tolstring

The problem was that for debugging something else, I did a call to lua_tostring(L, -1); after the lua_pushinteger(L, 48); and then according to the documentation: "If the value is a number, then lua_tolstring also changes the actual value in the stack to a string."

So I was able to fix my problem by just removing the call to lua_tostring() from my code.

However, I'm wondering why lua_tostring() behaves in this (somewhat surprising) manner? This makes it different from all the other lua_to*() functions, and I wonder why this is so??

Thanks, and best regards,
Carsten



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