Testing the creatures via scripts

I need to find some way to ensure type safety of userdata.
This commit is contained in:
2016-03-25 23:23:12 +11:00
parent 9a1714a881
commit e2f5494380
3 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ void CreatureManager::Update() {
int CreatureManager::Create(std::string avatar, int scriptRef) {
//implicitly create the new object
elementMap.emplace(counter, CreatureData(avatar, scriptRef));
elementMap.emplace( std::pair<int, CreatureData>(counter, CreatureData(avatar, scriptRef)) );
//TODO: do various things like saving to the database
return counter++;
@@ -23,6 +23,7 @@
#include "creature_manager.hpp"
//args: mgr, avatar, script
static int create(lua_State* L) {
CreatureManager* mgr = static_cast<CreatureManager* const>(lua_touserdata(L, 1));
int index = mgr->Create(lua_tostring(L, 2), lua_tointeger(L, 3));