diff --git a/source/module/LuaBinding.cpp b/source/module/LuaBinding.cpp index 557f969..f001ddb 100644 --- a/source/module/LuaBinding.cpp +++ b/source/module/LuaBinding.cpp @@ -40,6 +40,22 @@ int LuaBinding::navLoad(lua_State* luaVM) return 1; } +int LuaBinding::navSave(lua_State* luaVM) +{ + if (lua_type(luaVM, 1) != LUA_TSTRING) { + lua_pushboolean(luaVM, false); + return 1; + } + + auto& navigation = Navigation::GetInstance(); + + const char* path = lua_tostring(luaVM, 1); + const bool result = navigation.Save(path); + + lua_pushboolean(luaVM, result); + return 1; +} + int LuaBinding::navFindPath(lua_State* luaVM) { if (lua_gettop(luaVM) != 6) { diff --git a/source/module/LuaBinding.h b/source/module/LuaBinding.h index 25f2f6d..727ca8e 100644 --- a/source/module/LuaBinding.h +++ b/source/module/LuaBinding.h @@ -13,6 +13,7 @@ class LuaBinding public: static int navState(lua_State* luaVM); static int navLoad(lua_State* luaVM); + static int navSave(lua_State* luaVM); static int navFindPath(lua_State* luaVM); static int navNearestPoint(lua_State* luaVM); static int navDump(lua_State* luaVM); diff --git a/source/module/Module.cpp b/source/module/Module.cpp index 9a0de44..9989755 100644 --- a/source/module/Module.cpp +++ b/source/module/Module.cpp @@ -28,6 +28,7 @@ MTAEXPORT void RegisterFunctions(lua_State* luaVM) { pModuleManager->RegisterFunction(luaVM, "navState", LuaBinding::navState); pModuleManager->RegisterFunction(luaVM, "navLoad", LuaBinding::navLoad); + pModuleManager->RegisterFunction(luaVM, "navSave", LuaBinding::navSave); pModuleManager->RegisterFunction(luaVM, "navFindPath", LuaBinding::navFindPath); pModuleManager->RegisterFunction(luaVM, "navNearestPoint", LuaBinding::navNearestPoint); pModuleManager->RegisterFunction(luaVM, "navDump", LuaBinding::navDump);