Implemented bare-bones character system API

I need to devise a way to update the clients about changes to their
characters directly from the lua scripts. This isn't too important per se,
but the pattern will be important for the monster and trigger systems.
This commit is contained in:
Kayne Ruse
2015-02-21 21:46:22 +11:00
parent 6a999a8a72
commit ddedc06e47
4 changed files with 85 additions and 11 deletions
+8 -10
View File
@@ -3,6 +3,7 @@ print("Lua script check")
mapMaker = require("map_maker")
mapSaver = require("map_saver")
roomSystem = require("room_system")
characterSystem = require("character_system")
local function dumpTable(t)
print(t)
@@ -11,26 +12,23 @@ local function dumpTable(t)
end
end
--debugging (only works correctly with one room)
globalTickTest = {
ticks = 0,
start = 0
}
--test the room hooks
roomSystem.RoomManager.SetOnCreate(function(room, index)
print("", "Creating room: ", roomSystem.Room.GetName(room), index)
globalTickTest.start = os.clock()
--called ~60 times per second
roomSystem.Room.SetOnTick(room, function(room)
globalTickTest.ticks = globalTickTest.ticks + 1
local character = characterSystem.CharacterManager.GetCharacter("handle")
if character ~= nil then
--debugging
local x, y = characterSystem.Character.GetOrigin(character)
print("character.Origin(x, y): ", x, y)
end
end)
end)
roomSystem.RoomManager.SetOnUnload(function(room, index)
print("", "Unloading room: ", roomSystem.Room.GetName(room), index)
print("Time: ", (os.clock() - globalTickTest.start), "Ticks: ", globalTickTest.ticks)
end)
--NOTE: room 0 is the first that the client asks for, therefore it must exist