Updated RoomManager and the API

This commit is contained in:
Kayne Ruse
2014-06-21 19:02:43 +10:00
parent a64411a567
commit e19b6fbc23
3 changed files with 66 additions and 27 deletions
+17 -2
View File
@@ -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) {