forked from jwcpp/jwEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.lua
More file actions
52 lines (47 loc) · 1.04 KB
/
Copy pathtypes.lua
File metadata and controls
52 lines (47 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Player = {}
Player.__index = Player
function Player:read(buffer)
self.name = buffer:getString();
if 4 + buffer:rpos() > buffer:wpos() then return false end
self.level = buffer:getInt32();
if self.level>=30 then
if 4 + buffer:rpos() > buffer:wpos() then return false end
self.msgcount = buffer:getInt32();
end
return true;
end
function Player:write(buffer)
buffer:pushString(self.name);
buffer:pushInt32(self.level);
if self.level>=30 then
buffer:pushInt32(self.msgcount);
end
end
function Player:new()
local o = {}
setmetatable(o, Player)
o.name = ""
o.level = 0
o.msgcount = 0
return o
end
Attr = {}
Attr.__index = Attr
function Attr:read(buffer)
if 4 + buffer:rpos() > buffer:wpos() then return false end
self.attack = buffer:getInt32();
if 4 + buffer:rpos() > buffer:wpos() then return false end
self.hp = buffer:getInt32();
return true;
end
function Attr:write(buffer)
buffer:pushInt32(self.attack);
buffer:pushInt32(self.hp);
end
function Attr:new()
local o = {}
setmetatable(o, Attr)
o.attack = 0
o.hp = 0
return o
end