Skip to content

Commit

Permalink
Add navSave fumction
Browse files Browse the repository at this point in the history
  • Loading branch information
tederis committed Oct 18, 2023
1 parent 81dadfe commit 2ac53b9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/module/LuaBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions source/module/LuaBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions source/module/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2ac53b9

Please sign in to comment.