lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


We use tolua for the interfacing of lua<->c++.
For registering objects created in c++ to lua we use the following small
code snippet:

void CUtlLua::SetGlobal(const char *_sVarName, void *_pData, const char
*_sTagName)
{
    lua_pushusertag(pLuaState, _pData, tolua_tag(pLuaState, _sTagName));
    lua_setglobal(pLuaState, _sVarName);
}

The same method would probably be applied to other wrapper systems. The key
to the solution is to assign the object pointer the correct tag.

Greets,

  Dirk

-----Original Message-----
From: owner-lua-l@tecgraf.puc-rio.br
[mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Robert Sadedin
Sent: Sunday, June 16, 2002 10:55 PM
To: Multiple recipients of list
Subject: C++ creation of object, and Lua co-calling


For my game scripting, I need to be able to expose methods from objects
created in my c++ class to Lua.

I know there are a number of solutions for providing c++ classes in lua so
long as they are created in Lua, but what about when the construction is in
the host application?

Essentially, I need method sharing with the creation process being
consumated by the c++ app.

What is the simplest, and least ambitious method for doing this that you
experts can think of?


Thanks,



Rob