Skip to content

Commit fee5171

Browse files
octaciannerzhul
authored andcommittedJun 6, 2017
Main Menu: Add get_clientmodpath API (#5912)
Add `core.get_clientmodpath` to main menu API (also possible in async calls).
1 parent b3dfe53 commit fee5171

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed
 

‎doc/menu_lua_api.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ core.get_builtin_path()
3535
^ returns path to builtin root
3636
core.get_modpath() (possible in async calls)
3737
^ returns path to global modpath
38+
core.get_clientmodpath() (possible in async calls)
39+
^ returns path to global client-side modpath
3840
core.get_modstore_details(modid) (possible in async calls)
3941
^ modid numeric id of mod in modstore
4042
^ returns {
@@ -234,7 +236,7 @@ Limitations of Async operations
234236
-Limited set of available functions
235237
e.g. No access to functions modifying menu like core.start,core.close,
236238
core.file_open_dialog
237-
239+
238240

239241
Class reference
240242
----------------

‎src/script/lua_api/l_mainmenu.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,15 @@ int ModApiMainMenu::l_get_modpath(lua_State *L)
734734
return 1;
735735
}
736736

737+
/******************************************************************************/
738+
int ModApiMainMenu::l_get_clientmodpath(lua_State *L)
739+
{
740+
std::string modpath = fs::RemoveRelativePathComponents(
741+
porting::path_user + DIR_DELIM + "clientmods" + DIR_DELIM);
742+
lua_pushstring(L, modpath.c_str());
743+
return 1;
744+
}
745+
737746
/******************************************************************************/
738747
int ModApiMainMenu::l_get_gamepath(lua_State *L)
739748
{
@@ -1120,6 +1129,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
11201129
API_FCT(set_topleft_text);
11211130
API_FCT(get_mapgen_names);
11221131
API_FCT(get_modpath);
1132+
API_FCT(get_clientmodpath);
11231133
API_FCT(get_gamepath);
11241134
API_FCT(get_texturepath);
11251135
API_FCT(get_texturepath_share);
@@ -1150,6 +1160,7 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
11501160
API_FCT(get_favorites);
11511161
API_FCT(get_mapgen_names);
11521162
API_FCT(get_modpath);
1163+
API_FCT(get_clientmodpath);
11531164
API_FCT(get_gamepath);
11541165
API_FCT(get_texturepath);
11551166
API_FCT(get_texturepath_share);
@@ -1162,4 +1173,3 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
11621173
API_FCT(get_modstore_list);
11631174
//API_FCT(gettext); (gettext lib isn't threadsafe)
11641175
}
1165-

‎src/script/lua_api/l_mainmenu.h

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ class ModApiMainMenu: public ModApiBase
108108

109109
static int l_get_modpath(lua_State *L);
110110

111+
static int l_get_clientmodpath(lua_State *L);
112+
111113
static int l_get_gamepath(lua_State *L);
112114

113115
static int l_get_texturepath(lua_State *L);

0 commit comments

Comments
 (0)
Please sign in to comment.