In a class called Test_Class, I have a function :
shoot_a_bullet(int damage)
{
cout << "runned"; // i had #using namespace std
}
I had defined the code like following
luabind::module(myLuaState)[
luabind::def("shoot_a_bullet", &Test_Class::shoot_a_bullet)
];
And follow code didn't give me an output on screen
luaL_dostring(myLuaState,"shoot_a_bullet(134)\n");
PS:I did put cin.get() at the end, that's not the problem.
edit:
My main purpose of doing this is to let my scripted Character/Enemies able to directly adding stuff to a vector that hold bullets/effect/enemies and ect.
The reason i can't make the function static is because i need the pointer of main game stage to let it work.
following codes works fine
void print_hello(int number) {
cout << "hello world and : " << number << endl << "number from main : " << x << endl;
}
int x; //and the main with a global value
int main()
{
cin >> x;
lua_State *myLuaState = luaL_newstate();
luabind::open(myLuaState);
luabind::module(myLuaState)[
luabind::def("print_hello", print_hello)
];
luaL_dostring(
myLuaState,
"print_hello(123)\n"
);
cin.get();
cin.get();
lua_close(myLuaState);
}
I need a way to do this in a class that's not main