In my script I've got this global variable:
name = "Stabilizer"
And, I'm trying to fetch this variable in c++, like so:
char* CeScript::GetGlobalString(char* pName)
{
luaL_loadstring(L, m_sScript.c_str());
lua_getglobal(L, pName);
return (char*)lua_tostring(L, -1);
}
....
char* _name = pScript->GetGlobalString("name");
But, lua_tostring returns a null ptr, suggesting that the global variable could not be found.
What could be the issue? Thank you.