/* Run the function at the top of the stack, which returns an actor description * table. If the table was returned, return true and leave it on the stack. * If not, display an error, return false, and leave nothing on the stack. */ bool ActorUtil::LoadTableFromStackShowErrors( Lua *L ) { LuaReference func; lua_pushvalue( L, -1 ); func.SetFromStack( L ); RString Error= "Lua runtime error: "; if( !LuaHelpers::RunScriptOnStack(L, Error, 0, 1, true) ) { lua_pop( L, 1 ); return false; } if( lua_type(L, -1) != LUA_TTABLE ) { lua_pop( L, 1 ); func.PushSelf( L ); lua_Debug debug; lua_getinfo( L, ">nS", &debug ); Error = ssprintf( "%s: must return a table", debug.short_src ); LuaHelpers::ReportScriptError(Error, "LUA_ERROR"); return false; } return true; }
apActorCommands ActorUtil::ParseActorCommands( const RString &sCommands, const RString &sName ) { Lua *L = LUA->Get(); LuaHelpers::ParseCommandList( L, sCommands, sName, false ); LuaReference *pRet = new LuaReference; pRet->SetFromStack( L ); LUA->Release( L ); return apActorCommands( pRet ); }
static void GetGlobalTable( Lua *L ) { static LuaReference UserDataTable; if( !UserDataTable.IsSet() ) { lua_newtable( L ); UserDataTable.SetFromStack( L ); } UserDataTable.PushSelf( L ); }
static int Broadcast( T* p, lua_State *L ) { if( !lua_istable(L, 2) && !lua_isnoneornil(L, 2) ) luaL_typerror( L, 2, "table or nil" ); LuaReference ParamTable; lua_pushvalue( L, 2 ); ParamTable.SetFromStack( L ); Message msg( SArg(1), ParamTable ); p->Broadcast( msg ); COMMON_RETURN_SELF; }
void ActorScroller::LoadFromNode( const XNode *pNode ) { ActorFrame::LoadFromNode( pNode ); Load2(); float fNumItemsToDraw = 0; if( pNode->GetAttrValue("NumItemsToDraw", fNumItemsToDraw) ) SetNumItemsToDraw( fNumItemsToDraw ); float fSecondsPerItem = 0; if( pNode->GetAttrValue("SecondsPerItem", fSecondsPerItem) ) ActorScroller::SetSecondsPerItem( fSecondsPerItem ); Lua *L = LUA->Get(); pNode->PushAttrValue( L, "TransformFunction" ); { LuaReference ref; ref.SetFromStack( L ); if( !ref.IsNil() ) SetTransformFromReference( ref ); } LUA->Release( L ); int iSubdivisions = 1; if( pNode->GetAttrValue("Subdivisions", iSubdivisions) ) ActorScroller::SetNumSubdivisions( iSubdivisions ); bool bUseMask = false; pNode->GetAttrValue( "UseMask", bUseMask ); if( bUseMask ) { pNode->GetAttrValue( "MaskWidth", m_fMaskWidth ); pNode->GetAttrValue( "MaskHeight", m_fMaskHeight ); EnableMask( m_fMaskWidth, m_fMaskHeight ); } pNode->GetAttrValue( "QuantizePixels", m_fQuantizePixels ); pNode->GetAttrValue( "LoopScroller", m_bLoop ); pNode->GetAttrValue( "WrapScroller", m_bWrap ); }
void XNodeLuaValue::SetValueFromStack( lua_State *L ) { m_Value.SetFromStack( L ); }
template<> bool FromStack<LuaReference>( lua_State *L, LuaReference &Object, int iOffset ) { lua_pushvalue( L, iOffset ); Object.SetFromStack( L ); return true; }