[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How do I pass a pointer to a lua function into C++?
- From: Colm Sloan <colmsloan@...>
- Date: Fri, 7 Aug 2009 14:58:17 +0100
I figured it out. I just cahnged the lua_State* to luabind::object like so:
Timer::Timer( float delay, int repetitions, luabind::object luaFunction ) :
m_fDelay( delay ), m_iRepetitions( repetitions ), m_fInitialTime(
gpGlobals->curtime )
{
if ( luabind::type( luaFunction ) != LUA_TFUNCTION )
throw std::runtime_error("Invalid parameter for Timer constructor. A
function must be used\n");
m_luaFunction = luaFunction;
}
void Timer::Execute()
{
m_luaFunction();
}
I honestly don't know the non-luabind way and I'm curious about it but
this will do.