Filled out the APIs a bit
This commit is contained in:
+10
-13
@@ -21,28 +21,25 @@
|
||||
*/
|
||||
#include "room_api.hpp"
|
||||
|
||||
#include "room_manager.hpp"
|
||||
#include "room_data.hpp"
|
||||
|
||||
static int getType(lua_State* L) {
|
||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||
lua_pushinteger(L, static_cast<int>(room->type));
|
||||
return 1;
|
||||
}
|
||||
|
||||
//TODO: parameters
|
||||
|
||||
static int getRegionPager(lua_State* L) {
|
||||
static int getPager(lua_State* L) {
|
||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||
lua_pushlightuserdata(L, reinterpret_cast<void*>(&room->pager));
|
||||
return 1;
|
||||
}
|
||||
|
||||
//TODO: generators
|
||||
static int getGenerator(lua_State* L) {
|
||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||
lua_pushlightuserdata(L, reinterpret_cast<void*>(room->generator));
|
||||
return 1;
|
||||
}
|
||||
|
||||
//TODO: parameters
|
||||
|
||||
static const luaL_Reg roomlib[] = {
|
||||
{"gettype",getType},
|
||||
{"getregionpager",getRegionPager},
|
||||
{"getpager",getPager},
|
||||
{"getgenerator",getGenerator},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
struct RoomData {
|
||||
//members
|
||||
MapType type;
|
||||
RegionPagerLua pager;
|
||||
BaseGenerator* generator = nullptr;
|
||||
|
||||
|
||||
@@ -35,8 +35,33 @@ static int getRoom(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int createRoom(lua_State* L) {
|
||||
//get the room manager
|
||||
lua_pushstring(L, ROOM_MANAGER_PSEUDOINDEX);
|
||||
lua_gettable(L, LUA_REGISTRYINDEX);
|
||||
RoomManager* roomMgr = reinterpret_cast<RoomManager*>(lua_touserdata(L, -1));
|
||||
|
||||
//TODO: create room
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int unloadRoom(lua_State* L) {
|
||||
//get the room manager
|
||||
lua_pushstring(L, ROOM_MANAGER_PSEUDOINDEX);
|
||||
lua_gettable(L, LUA_REGISTRYINDEX);
|
||||
RoomManager* roomMgr = reinterpret_cast<RoomManager*>(lua_touserdata(L, -1));
|
||||
|
||||
//unload the specified room
|
||||
roomMgr->UnloadRoom(lua_tointeger(L, -2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg roommgrlib[] = {
|
||||
{"getroom",getRoom},
|
||||
{"createroom",createRoom},
|
||||
{"unloadroom",unloadRoom},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user