[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Functions spanning Namespaced and Header files
- From: Austen Higgins-Cassidy <austen@...>
- Date: Sat, 20 Sep 2008 09:18:20 -0400
Hi everyone.
I'm new to Lua but I've been programming in C++ for a few years.
I'm having a problem registering functions that are in other files than
my main.cpp file. I have two functions which are identical except for
the name and the scope in which they reside. On function is in the
global scope of the main.cpp file and the other is in a Base namespace
in my script.h file. I try to register and use both of them in a script.
The global one works as it is supposed to, however, the Base/script.h
function seems to simply be skipped in the script.
I am using ToLua++ to aid my transition to Lua scripting (cause it is
nice to be able to use my structures as native types, it's just
difficult sending them back and forth!).
the function body is:
int GetPlayerA(lua_State *lua);
int Base::GetPlayerA(lua_State *lua){
tolua_pushusertype(lua,(void*)&Base::Player,"Base::Character");
return 0;
}
And here is the script I am executing:
SetY(4);
a = PlayerGet();
b = GetPlayerA();
PrintC("Player Get");
SetY(5);
PrintC(a:GetName(0));
SetY(6);
PrintC("GetPlayerA");
SetY(7);
PrintC(b:GetName());
SetY(8);
ShowC();
SecWait();
Name is an std::string member. The output of the script is
Player Get
Playername!
GetPlayerA
So at least the function is written correctly (I hope).
Anyway, I've been desperately trying to finagle this for the last few
days and I could use a little help!
Thanks!