Making non-static class member function available to Lua.
tjhowse <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Let me outline what I'm trying to do.
I have a base entity class, from this I derive all the other kinds of
entities in my game. One of these entities is named "lua_component". It is a
component of a weapon whos behavior is described by a short Lua script. I do
this such that someone can add their own custom weapon components with
custom script inside. The components communicate with each-other by means of
a signaling function in the C++ master program that works out which I/O of
which components is connected to any others, and routes the signals around
accordingly.
My problem arises when a "FIRE" signal reaches the muzzle component of a
constructed weapon. I want to be able to call a "spawn_entity" function from
Lua, and pass the C++ master program a struct containing everything it needs
to know to spawn a projectile entity.
Each component has its own "lua_State* lua_object", and own "void
spawn_entity(int arg)" function. In the constructor of my lua_component
class I bind the spawn_entity thus:
lua_object = lua_open();
luaL_openlibs(lua_object);
luabind::open(lua_object);
luabind::module(lua_object) [
luabind::def("spawn_entity", &lua_component::spawn_entity)
];
So far so good, however, when I call spawn_entity from within Lua:
luaL_dostring(
lua_object,
"spawn_entity(4)\n"
);
I get the following dumped onto the stack:
"No matching overload found, candidates:
void spawn_entity(custom [class lua_component]&,int)" char *
What am I doing wrong? is what I'm trying to do fundamentally impossible?
Binding a non-static class member variable into a Lua machine?
Thanks,
tjhowse.
--
View this message in context: http://old.nabble.com/Making-non-static-class-member-function-available-to-Lua.-tp26462873p26462873.html
Sent from the Lua C++ Bind mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july