Add lua GetPreference(). Takes a string, adds the value in the correct

type.  I'm not sure if we want to give Preferences an actual Lua object;
this is just a simple (if somewhat slow) way to get read access to all
preference values.
This commit is contained in:
Glenn Maynard
2005-01-30 02:04:57 +00:00
parent ef12eea2d4
commit ee81c02d45
+24 -1
View File
@@ -840,8 +840,31 @@ Premium PrefsManager::GetPremium()
return m_Premium;
}
#include "RageLog.h"
#include "LuaFunctions.h"
int LuaFunc_GetPreference( lua_State *L )
{
REQ_ARGS( "GetPreference", 1 );
REQ_ARG( "GetPreference", 1, string );
CString sName;
LUA->PopStack( sName );
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;
}
LuaFunction( GetPreference ); /* register it */
LuaFunction_NoArgs( EventMode, PREFSMAN->m_bEventMode )
LuaFunction_NoArgs( ShowCaution, PREFSMAN->m_bShowCaution )