Testing the creatures via scripts
I need to find some way to ensure type safety of userdata.
This commit is contained in:
@@ -35,14 +35,23 @@ mapSaver = require("map_saver")
|
|||||||
|
|
||||||
doorUtility = require("door_utility")
|
doorUtility = require("door_utility")
|
||||||
|
|
||||||
|
creatureAPI = require("creature")
|
||||||
|
creatureManagerAPI = require("creature_manager")
|
||||||
|
|
||||||
--test the room hooks
|
--test the room hooks
|
||||||
roomManagerAPI.SetOnCreate(function(room, index)
|
roomManagerAPI.SetOnCreate(function(room, index)
|
||||||
print("", "Creating room: ", roomAPI.GetName(room), index)
|
print("", "Creating room: ", roomAPI.GetName(room), index)
|
||||||
|
|
||||||
|
creatureManagerAPI.Create(roomAPI.GetCreatureMgr(room), "anibunny.png", function() --[[]] end)
|
||||||
|
|
||||||
roomAPI.SetOnTick(room, function(room)
|
roomAPI.SetOnTick(room, function(room)
|
||||||
roomAPI.ForEachCharacter(room, function(character)
|
roomAPI.ForEachCharacter(room, function(character)
|
||||||
--
|
--
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
roomAPI.ForEachCreature(room, function(creature)
|
||||||
|
--
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void CreatureManager::Update() {
|
|||||||
|
|
||||||
int CreatureManager::Create(std::string avatar, int scriptRef) {
|
int CreatureManager::Create(std::string avatar, int scriptRef) {
|
||||||
//implicitly create the new object
|
//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
|
//TODO: do various things like saving to the database
|
||||||
return counter++;
|
return counter++;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "creature_manager.hpp"
|
#include "creature_manager.hpp"
|
||||||
|
|
||||||
|
//args: mgr, avatar, script
|
||||||
static int create(lua_State* L) {
|
static int create(lua_State* L) {
|
||||||
CreatureManager* mgr = static_cast<CreatureManager* const>(lua_touserdata(L, 1));
|
CreatureManager* mgr = static_cast<CreatureManager* const>(lua_touserdata(L, 1));
|
||||||
int index = mgr->Create(lua_tostring(L, 2), lua_tointeger(L, 3));
|
int index = mgr->Create(lua_tostring(L, 2), lua_tointeger(L, 3));
|
||||||
|
|||||||
Reference in New Issue
Block a user