Established a connection between the Region objects and lua
This commit is contained in:
@@ -42,7 +42,7 @@ void LuaGenerator::Create(Region** const ptr, int width, int height, int depth,
|
|||||||
|
|
||||||
//generate the lua-driven maps
|
//generate the lua-driven maps
|
||||||
lua_getglobal(state, "CreateRegion");
|
lua_getglobal(state, "CreateRegion");
|
||||||
lua_pushlightuserdata(state, ptr);
|
lua_pushlightuserdata(state, *ptr);
|
||||||
lua_pcall(state, 1, 0, 0);
|
lua_pcall(state, 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,53 @@
|
|||||||
*/
|
*/
|
||||||
#include "region_api.hpp"
|
#include "region_api.hpp"
|
||||||
|
|
||||||
LUAMOD_API int luaopen_regionapi(lua_State* L) {
|
#include "region.hpp"
|
||||||
//TODO: stuff
|
|
||||||
|
static int setTile(lua_State* L) {
|
||||||
|
// Region* ptr = lua_touserdata(L, 1);
|
||||||
|
// ptr->SetTile
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getTile(lua_State* L) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getWidth(lua_State* L) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getHeight(lua_State* L) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getDepth(lua_State* L) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getX(lua_State* L) {
|
||||||
|
Region* ptr = (Region*)lua_touserdata(L, 1);
|
||||||
|
lua_pushinteger(L, ptr->GetX());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int getY(lua_State* L) {
|
||||||
|
Region* ptr = (Region*)lua_touserdata(L, 1);
|
||||||
|
lua_pushinteger(L, ptr->GetY());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const luaL_Reg regionlib[] = {
|
||||||
|
{"SetTile",setTile},
|
||||||
|
{"GetTile",getTile},
|
||||||
|
{"GetWidth",getWidth},
|
||||||
|
{"GetHeight",getHeight},
|
||||||
|
{"GetDepth",getDepth},
|
||||||
|
{"GetX",getX},
|
||||||
|
{"GetY",getY},
|
||||||
|
{nullptr, nullptr}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUAMOD_API int luaopen_regionapi(lua_State* L) {
|
||||||
|
luaL_newlib(L, regionlib);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "lua/lua.hpp"
|
#include "lua/lua.hpp"
|
||||||
|
|
||||||
#define LUA_REGIONLIBNAME "region"
|
#define LUA_REGIONLIBNAME "Region"
|
||||||
LUAMOD_API int luaopen_regionapi(lua_State* L);
|
LUAMOD_API int luaopen_regionapi(lua_State* L);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
print("Lua script check OK")
|
print("Lua script check OK (./rsc)")
|
||||||
|
|
||||||
|
function CreateRegion(r)
|
||||||
|
print(Region.GetX(r), Region.GetY(r))
|
||||||
|
end
|
||||||
@@ -110,6 +110,10 @@ void ServerApplication::Init(int argc, char** argv) {
|
|||||||
|
|
||||||
//finalize the startup
|
//finalize the startup
|
||||||
cout << "Startup completed successfully" << endl;
|
cout << "Startup completed successfully" << endl;
|
||||||
|
|
||||||
|
//debugging
|
||||||
|
mapPager.GetRegion(0,0);
|
||||||
|
mapPager.GetRegion(128,256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::Loop() {
|
void ServerApplication::Loop() {
|
||||||
|
|||||||
Reference in New Issue
Block a user