Updated RoomManager and the API
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include "room_manager.hpp"
|
||||
#include "room_data.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
static int getRoom(lua_State* L) {
|
||||
//get the room manager
|
||||
lua_pushstring(L, ROOM_MANAGER_PSEUDOINDEX);
|
||||
@@ -41,9 +43,22 @@ static int createRoom(lua_State* L) {
|
||||
lua_gettable(L, LUA_REGISTRYINDEX);
|
||||
RoomManager* roomMgr = reinterpret_cast<RoomManager*>(lua_touserdata(L, -1));
|
||||
|
||||
//TODO: create room
|
||||
//determine the specified room type
|
||||
MapType mapType = [L]() -> MapType {
|
||||
if (std::string("overworld") == lua_tostring(L, -2)) return MapType::OVERWORLD;
|
||||
if (std::string("ruins") == lua_tostring(L, -2)) return MapType::RUINS;
|
||||
if (std::string("towers") == lua_tostring(L, -2)) return MapType::TOWERS;
|
||||
if (std::string("forests") == lua_tostring(L, -2)) return MapType::FORESTS;
|
||||
if (std::string("caves") == lua_tostring(L, -2)) return MapType::CAVES;
|
||||
return MapType::NONE;
|
||||
}();
|
||||
|
||||
return 0;
|
||||
//create the room
|
||||
int newIndex = roomMgr->CreateRoom(mapType);
|
||||
|
||||
//return the index
|
||||
lua_pushinteger(L, newIndex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int unloadRoom(lua_State* L) {
|
||||
|
||||
Reference in New Issue
Block a user