From ee81c02d45c07c9e1d568e021c91f1b7111056af Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 30 Jan 2005 02:04:57 +0000 Subject: [PATCH] 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. --- stepmania/src/PrefsManager.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index b773728d7a..8765c88e36 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -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 )