aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-09-19 17:55:01 +0200
committersfan5 <sfan5@live.de>2021-10-07 00:20:01 +0200
commit2b5075f0e2a8223cdb07f000b7e8f874416ed3a8 (patch)
tree74cfcd8e0f5e4d906e465960bc125829806f9095 /src/script/lua_api
parent2d5b7b5fb48d182fbab8e4ad69e9a552a3c07c6e (diff)
downloadminetest-2b5075f0e2a8223cdb07f000b7e8f874416ed3a8.tar.gz
minetest-2b5075f0e2a8223cdb07f000b7e8f874416ed3a8.tar.bz2
minetest-2b5075f0e2a8223cdb07f000b7e8f874416ed3a8.zip
Move archive extraction in content store to async job
Diffstat (limited to 'src/script/lua_api')
-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);
}