Example #1
0
	static int PostScreenMessage( T* p, lua_State *L )
	{
		RString sMessage = SArg(1);
		ScreenMessage SM = ScreenMessageHelpers::ToScreenMessage( sMessage );
		p->PostScreenMessage( SM, IArg(2) );
		return 0;
	}
Example #2
0
	static int SHA1File( T* p, lua_State *L )
	{
		RString sha1fout;
		sha1fout = p->GetSHA1ForFile(SArg(1));
		lua_pushstring( L, sha1fout );
		return 1;
	}
Example #3
0
	static int MD5File( T* p, lua_State *L )
	{
		RString md5fout;
		md5fout = p->GetMD5ForFile(SArg(1));
		lua_pushstring( L, md5fout );
		return 1;
	}
Example #4
0
int LuaFunc_color( lua_State *L )
{
	RString sColor = SArg(1);
	RageColor c;
	c.FromString( sColor );
	c.PushTable( L );
	return 1;
}
 static int SetCurrentAnnouncer( T* p, lua_State *L )
 {
     RString s = SArg(1);
     // only bother switching if the announcer exists. -aj
     if(p->DoesAnnouncerExist(s))
         p->SwitchAnnouncer(s);
     COMMON_RETURN_SELF;
 }
Example #6
0
	static int LoadBanner( T* p, lua_State *L )
	{
		RageTextureID ID( SArg(1) );
		TEXTUREMAN->DisableOddDimensionWarning();
		p->Load( Sprite::SongBannerTexture(ID) );
		TEXTUREMAN->EnableOddDimensionWarning();
		return 1;
	}
	static int SetPlayerOptions( T* p, lua_State *L )
	{
		ModsLevel m = Enum::Check<ModsLevel>( L, 1 );
		PlayerOptions po;
		po.FromString( SArg(2) );
		p->m_PlayerOptions.Assign( m, po );
		return 0;
	}
	static int GetCharacter( T* p, lua_State *L )
	{
		Character *pCharacter = p->GetCharacterFromID(SArg(1));
		if( pCharacter != NULL )
			pCharacter->PushSelf( L );
		else
			lua_pushnil( L );

		return 1;
	}
Example #9
0
	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;
	}
Example #10
0
	static int Load( T* p, lua_State *L )
	{
		if( lua_isnil(L, 1) )
		{
			p->UnloadTexture();
		}
		else
		{
			RageTextureID ID( SArg(1) );
			p->Load( ID );
		}
		COMMON_RETURN_SELF;
	}
Example #11
0
 static int GetPreference( T* p, lua_State *L )
 {
     CString sName = SArg(1);
     IPreference *pPref = PREFSMAN->GetPreferenceByName( sName );
     if( pPref == NULL )
     {
         LOG->Warn( "GetPreference: unknown preference \"%s\"", sName.c_str() );
         lua_pushnil( L );
     }
     else
     {
         pPref->PushValue( L );
     }
     return 1;
 }
Example #12
0
	static int SetFromString( T* p, lua_State *L )
	{
		RString sDisplayTitle = SArg(1);
		RString sTranslitTitle = SArg(2);
		RString sDisplaySubTitle = SArg(3);
		RString sTranslitSubTitle = SArg(4);
		RString sDisplayArtist = SArg(5);
		RString sTranslitArtist = SArg(6);
  		p->SetFromString( sDisplayTitle, sTranslitTitle, sDisplaySubTitle, sTranslitSubTitle, sDisplayArtist, sTranslitArtist );
		COMMON_RETURN_SELF;
	}
Example #13
0
    static int SetPreference( T* p, lua_State *L )
    {
        CString sName = SArg(1);

        IPreference *pPref = PREFSMAN->GetPreferenceByName( sName );
        if( pPref == NULL )
        {
            LOG->Warn( "GetPreference: unknown preference \"%s\"", sName.c_str() );
        }
        else
        {
            lua_pushvalue( L, 2 );
            pPref->SetFromStack( L );
        }
        PREFSMAN->SaveGlobalPrefsToDisk();

        return 0;
    }
Example #14
0
	static int PutLine( T* p, lua_State *L )
	{
		can_safely_write(p, L);
		lua_pushinteger( L, p->PutLine( SArg(1) ) );
		return 1;
	}
Example #15
0
	static int Open( T* p, lua_State *L )
	{
		lua_pushboolean( L, p->Open( SArg(1), IArg(2) ) );
		return 1;
	}
Example #16
0
	static int PutLine( T* p, lua_State *L )
	{
		lua_pushinteger( L, p->PutLine( SArg(1) ) );
		return 1;
	}
Example #17
0
	static int Write( T* p, lua_State *L )
	{
		lua_pushinteger( L, p->Write( SArg(1) ) );
		return 1;
	}
Example #18
0
	static int LoadFromSongGroup( T* p, lua_State *L )
	{ 
		p->LoadFromSongGroup( SArg(1) );
		return 0;
	}
Example #19
0
	static int Load( T* p, lua_State *L )		{ p->Load( SArg(1), nullptr ); COMMON_RETURN_SELF; }
Example #20
0
	static int Load( T* p, lua_State *L )		{ p->Load( SArg(1), NULL ); return 0; }
void ScreenSelect::Init()
{
	IDLE_COMMENT_SECONDS.Load( m_sName, "IdleCommentSeconds" );
	IDLE_TIMEOUT_SECONDS.Load( m_sName, "IdleTimeoutSeconds" );
	ALLOW_DISABLED_PLAYER_INPUT.Load( m_sName, "AllowDisabledPlayerInput" );

	ScreenWithMenuElements::Init();

	// Load messages to update on
	split( UPDATE_ON_MESSAGE, ",", m_asSubscribedMessages );
	for( unsigned i = 0; i < m_asSubscribedMessages.size(); ++i )
		MESSAGEMAN->Subscribe( this, m_asSubscribedMessages[i] );
	// Subscribe to PlayerJoined, if not already.
	if( !MESSAGEMAN->IsSubscribedToMessage(this, Message_PlayerJoined) )
		this->SubscribeToMessage( Message_PlayerJoined );

	// Load choices
	// Allow lua as an alternative to metrics.
	RString choice_names= CHOICE_NAMES;
	if(choice_names.Left(4) == "lua,")
	{
		RString command= choice_names.Right(choice_names.size()-4);
		Lua* L= LUA->Get();
		if(LuaHelpers::RunExpression(L, command, m_sName + "::ChoiceNames"))
		{
			if(!lua_istable(L, 1))
			{
				LuaHelpers::ReportScriptError(m_sName + "::ChoiceNames expression did not return a table of gamecommands.");
			}
			else
			{
				size_t len= lua_objlen(L, 1);
				for(size_t i= 1; i <= len; ++i)
				{
					lua_rawgeti(L, 1, i);
					if(!lua_isstring(L, -1))
					{
						LuaHelpers::ReportScriptErrorFmt(m_sName + "::ChoiceNames element %zu is not a string.", i);
					}
					else
					{
						RString com= SArg(-1);
						GameCommand mc;
						mc.ApplyCommitsScreens(false);
						mc.m_sName = ssprintf("%zu", i);
						Commands cmd= ParseCommands(com);
						mc.Load(i, cmd);
						m_aGameCommands.push_back(mc);
					}
					lua_pop(L, 1);
				}
			}
		}
		lua_settop(L, 0);
		LUA->Release(L);
	}
	else
	{
		// Instead of using NUM_CHOICES, use a comma-separated list of choices.
		// Each element in the list is a choice name. This level of indirection 
		// makes it easier to add or remove items without having to change a
		// bunch of indices.
		vector<RString> asChoiceNames;
		split( CHOICE_NAMES, ",", asChoiceNames, true );

		for( unsigned c=0; c<asChoiceNames.size(); c++ )
		{
			RString sChoiceName = asChoiceNames[c];

			GameCommand mc;
			mc.ApplyCommitsScreens( false );
			mc.m_sName = sChoiceName;
			Commands cmd = ParseCommands( CHOICE(sChoiceName) );
			mc.Load( c, cmd );
			m_aGameCommands.push_back( mc );
		}
	}

	if(m_aGameCommands.empty())
	{
		LuaHelpers::ReportScriptErrorFmt("Screen \"%s\" does not set any choices.", m_sName.c_str());
	}
}
	static int SetTextureName( T* p, lua_State *L )			{ p->SetTextureName(SArg(1)); COMMON_RETURN_SELF; }
Example #23
0
	static int Broadcast( T* p, lua_State *L )
	{
		p->Broadcast( SArg(1) );
		return 0;
	}
 static int DoesAnnouncerExist( T* p, lua_State *L ) {
     lua_pushboolean(L, p->DoesAnnouncerExist( SArg(1) ));
     return 1;
 }
Example #25
0
	static int LoadFromCachedBanner( T* p, lua_State *L )
	{ 
		p->LoadFromCachedBanner( SArg(1) );
		return 0;
	}
Example #26
0
	static int LoadFromSongGroup( T* p, lua_State *L )	{ p->LoadFromSongGroup( SArg(1) ); COMMON_RETURN_SELF; }
Example #27
0
	static int LoadFromCachedBanner( T* p, lua_State *L )
	{ 
		p->LoadFromCachedBanner( SArg(1) );
		COMMON_RETURN_SELF;
	}