aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mainmenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/lua_api/l_mainmenu.cpp')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 4cfbaec71..2a6a9c32d 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -563,7 +563,10 @@ int ModApiMainMenu::l_get_cache_path(lua_State *L)
/******************************************************************************/
int ModApiMainMenu::l_get_temp_path(lua_State *L)
{
- lua_pushstring(L, fs::TempPath().c_str());
+ if (lua_isnoneornil(L, 1) || !lua_toboolean(L, 1))
+ lua_pushstring(L, fs::TempPath().c_str());
+ else
+ lua_pushstring(L, fs::CreateTempFile().c_str());
return 1;
}
@@ -770,8 +773,9 @@ int ModApiMainMenu::l_get_video_drivers(lua_State *L)
/******************************************************************************/
int ModApiMainMenu::l_gettext(lua_State *L)
{
- std::string text = strgettext(std::string(luaL_checkstring(L, 1)));
- lua_pushstring(L, text.c_str());
+ const char *srctext = luaL_checkstring(L, 1);
+ const char *text = *srctext ? gettext(srctext) : "";
+ lua_pushstring(L, text);
return 1;
}
@@ -921,5 +925,5 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
API_FCT(download_file);
API_FCT(get_min_supp_proto);
API_FCT(get_max_supp_proto);
- //API_FCT(gettext); (gettext lib isn't threadsafe)
+ API_FCT(gettext);
}