diff --git a/src/gui/lua/lua_api_version.h b/src/gui/lua/lua_api_version.h index 481614a99..caaf598eb 100644 --- a/src/gui/lua/lua_api_version.h +++ b/src/gui/lua/lua_api_version.h @@ -4,4 +4,4 @@ * to luainstance.h changes */ #define LUA_API_VERSION_MAJOR 1 -#define LUA_API_VERSION_MINOR 92 +#define LUA_API_VERSION_MINOR 93 diff --git a/src/gui/lua/luainstance.cpp b/src/gui/lua/luainstance.cpp index 4df60cc91..7a12a2a14 100644 --- a/src/gui/lua/luainstance.cpp +++ b/src/gui/lua/luainstance.cpp @@ -414,6 +414,42 @@ static void set_lua_variables(lua_State *L) { NULL, 0 } }; + /* directories, exported as e.g. DIR['CONFIGDIR'] */ + table_key_s directories[] = + { + { "CONFIGDIR", CONFIGDIR }, + { "DATADIR", DATADIR }, + { "DATADIR_VAR", DATADIR_VAR }, + { "CONTROLDIR", CONTROLDIR }, + { "CONTROLDIR_VAR", CONTROLDIR_VAR }, + { "FONTDIR", FONTDIR }, + { "FONTDIR_VAR", FONTDIR_VAR }, + { "LIBDIR", LIBDIR }, + { "GAMESDIR", GAMESDIR }, + { "ICONSDIR", ICONSDIR }, + { "ICONSDIR_VAR", ICONSDIR_VAR }, + { "LOCALEDIR", LOCALEDIR }, + { "LOCALEDIR_VAR", LOCALEDIR_VAR }, + { "PLUGINDIR", PLUGINDIR }, + { "PLUGINDIR_MNT", PLUGINDIR_MNT }, + { "PLUGINDIR_VAR", PLUGINDIR_VAR }, + { "LUAPLUGINDIR", LUAPLUGINDIR }, + { "LUAPLUGINDIR_VAR", LUAPLUGINDIR_VAR }, + { "THEMESDIR", THEMESDIR }, + { "THEMESDIR_VAR", THEMESDIR_VAR }, + { "WEBRADIODIR", WEBRADIODIR }, + { "WEBRADIODIR_VAR", WEBRADIODIR_VAR }, + { "WEBTVDIR", WEBTVDIR }, + { "WEBTVDIR_VAR", WEBTVDIR_VAR }, + { "LOGODIR", LOGODIR }, + { "LOGODIR_VAR", LOGODIR_VAR }, + { "PRIVATE_HTTPDDIR", PRIVATE_HTTPDDIR }, + { "PUBLIC_HTTPDDIR", PUBLIC_HTTPDDIR }, + { "HOSTED_HTTPDDIR", HOSTED_HTTPDDIR }, + { "FLAGDIR", FLAGDIR }, + { NULL, 0 } + }; + /* list of environment variable arrays to be exported */ lua_envexport e[] = { @@ -467,6 +503,26 @@ static void set_lua_variables(lua_State *L) lua_setglobal(L, e_u[i].name); i++; } + + lua_envexport_s e_s[] = + { + { "DIR", directories }, + { NULL, NULL } + }; + + i = 0; + while (e_s[i].name) { + int j = 0; + lua_newtable(L); + while (e_s[i].t[j].name) { + lua_pushstring(L, e_s[i].t[j].name); + lua_pushstring(L, e_s[i].t[j].code); + lua_settable(L, -3); + j++; + } + lua_setglobal(L, e_s[i].name); + i++; + } } const char CLuaInstance::className[] = LUA_CLASSNAME; diff --git a/src/gui/lua/luainstance_helpers.h b/src/gui/lua/luainstance_helpers.h index 14dc5ad9c..52c0c1c95 100644 --- a/src/gui/lua/luainstance_helpers.h +++ b/src/gui/lua/luainstance_helpers.h @@ -91,6 +91,11 @@ struct table_key_u { lua_Unsigned code; }; +struct table_key_s { + const char *name; + const char *code; +}; + struct lua_envexport { const char *name; table_key *t; @@ -101,6 +106,11 @@ struct lua_envexport_u { table_key_u *t; }; +struct lua_envexport_s { + const char *name; + table_key_s *t; +}; + /* this is stored as userdata in the lua_State */ struct CLuaData {