I am very sorry choose a html format prev mail
I use luabind bind class cChar and it's member function Say
there is a lua script function like
function Hello(cChar* p)
--but how to pass the cChar to lua Function Hello in cpp file
lua_pushlightuserdata(L, p); //there must be wrong.
int error = lua_pcall(L, 1, 0,0);
Hi, since you havn't got any replies yet and I can give you some quick
pointers, here we go....
Sorry if I'm patronising in this reply as from the looks of it this is your
first go at luabind and you don't understand it completely yet. I don't
claim to know how it all works, but i've got it doing what i want so far.
Anyway, first of all you must "bind" your class into luabind, without doing
this you won't be able to do anything in lua using your classes. to do this
you do something like this:
class_<cChar>("cChar") //Bind my class to luabind and give it a
.def("Say",&cChar::Say) //tell luabind about the function "say"
which is in the class
Once you have run that function THEN you can perform a script like this:
Notice that the script does NOT have cChar *p in it, this is because lua is
dynamically typed, so p could effectivly be anything, (integer, string, or
even your class).
now to execute that function you would do something like this:
char *fileName = "test.lua";
//First run the script described above:
//Get the function object from lua
luabind::object globals = get_globals(luaState);
luabind::object function = globals["Hello"];
(function)(p); //Call the function
Now hopefully i've given you some ideas.. either that or i've confused you,
or i'm completely missing the point of your question (in which case i
imagine others will too)