diff --git a/common/map/map_system_api.cpp b/common/map/map_system_api.cpp new file mode 100644 index 0000000..65c0a10 --- /dev/null +++ b/common/map/map_system_api.cpp @@ -0,0 +1,46 @@ +/* Copyright: (c) Kayne Ruse 2014 + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. +*/ +#include "map_system_api.hpp" + +//all map API headers +#include "region_api.hpp" +#include "region_pager_api.hpp" +#include "tile_sheet.hpp" + +/* This mimics linit.c to create a nested collection of all map modules. +*/ + +static const luaL_Reg maplibs[] = { + {"Region", openRegionAPI}, + {"RegionPager", openRegionPagerAPI}, +// {"TileSheet", openTileSheetAPI}, + {nullptr, nullptr} +}; + +int openMapSystemAPI(lua_State* L) { + luaL_newlibtable(L, maplibs); + for (const luaL_Reg* lib = maplibs; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_setfield(L, -2, lib->name); + } + return 1; +} \ No newline at end of file diff --git a/common/map/map_system_api.hpp b/common/map/map_system_api.hpp new file mode 100644 index 0000000..10f2f94 --- /dev/null +++ b/common/map/map_system_api.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2014 + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. +*/ +#ifndef MAPSYSTEMAPI_HPP_ +#define MAPSYSTEMAPI_APP_ + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + +#define TORTUGA_MAP_SYSTEM_API "map_system" +LUAMOD_API int openMapSystemAPI(lua_State* L); + +#endif \ No newline at end of file diff --git a/common/map/region_api.hpp b/common/map/region_api.hpp index babbb4f..b276645 100644 --- a/common/map/region_api.hpp +++ b/common/map/region_api.hpp @@ -28,7 +28,7 @@ #include "lua.hpp" #endif -#define TORTUGA_REGION_NAME "Region" +#define TORTUGA_REGION_NAME "region" LUAMOD_API int openRegionAPI(lua_State* L); #endif diff --git a/common/map/region_pager_api.hpp b/common/map/region_pager_api.hpp index b4f8c7b..a8f9297 100644 --- a/common/map/region_pager_api.hpp +++ b/common/map/region_pager_api.hpp @@ -28,7 +28,7 @@ #include "lua.hpp" #endif -#define TORTUGA_REGION_PAGER_NAME "RegionPager" +#define TORTUGA_REGION_PAGER_NAME "region_pager" LUAMOD_API int openRegionPagerAPI(lua_State* L); #endif diff --git a/common/map/tile_sheet_api.hpp b/common/map/tile_sheet_api.hpp index 385a4b2..dc3d277 100644 --- a/common/map/tile_sheet_api.hpp +++ b/common/map/tile_sheet_api.hpp @@ -28,8 +28,7 @@ #include "lua.hpp" #endif - -#define TORTUGA_TILE_SHEET_NAME "TileSheet" +#define TORTUGA_TILE_SHEET_NAME "tile_sheet" LUAMOD_API int openTileSheetAPI(lua_State* L); #endif