lua-users home
lua-l archive

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


I have an unusual situation. I have an object in C++ that is given many many values in C++. I can grab this object and get its Lua equivalent:
// C++
m_LuaSelf = luabind::call_function<luabind::object>( L, "GetLuaSelf", this );

-- Lua
function GetLuaSelf( cSelf )
return cSelf -- returns a lua object with all of the C++ data still in it
end

I want to make it so I can create a Lua object that inherits all of the values associated with that C++ object. I made it so I pass the object to another class but it can't use the syntactical sugar of ":", making it feel very unnatural:

// C++
luabind::call_member<void>( m_LuaSelf, "Setup" );

-- Lua
function TheC++Class:Setup()
......... -- gets the other lua class name, which I'll class "MyTestClass"
_G[ self.luaClassName ][ 'Setup' ]( self )
end

function MyTestClass:Setup()
-- it reaches this point

-- how can functions in this class be called using the ':' (colon) instead '.' (period) e.g.
--self:bar() instead of
--MyTestNPC.Setup( self ) -- the only way I've found
end


I understand this is a complicated post so all input is appreciated.