lua-users home
lua-l archive

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


Your code looks OK to me. Is this the exact copy of your function source? May I suggest you step into lua_pushstring and track down where exactly it bombs (this may give you a clue)? What is going on between the two calls to GetString?
 
AB 
-----Original Message-----
From: Kevin Watters [mailto:kwatters@adelphia.net]
Sent: Wednesday, February 12, 2003 3:07 PM
To: Multiple recipients of list
Subject: Newbie help

I'm writing (yet another) C++ wrapper for Lua (5.0b) and I'm having serious problems with a function that should be very very simple :)  Here's my code to get a global string:
*****************************************
std::string Cscript::GetString(char *varName)
{
 std::string str;
 
 lua_pushstring(lua, varName);
 lua_gettable(lua, LUA_GLOBALSINDEX);
 str = lua_tostring(lua,lua_gettop(lua));
 lua_pop(lua,1);
 
 return str;
}
*********************************
It works like expected the first time, but then the second time I call it it crashes on the lua_pushstring line.  What am I doing wrong?