2012-08-30 07:59:10 +02:00
|
|
|
function InputMessage:getData()
|
|
|
|
local dataType = self:getU8()
|
|
|
|
if dataType == NetworkMessageTypes.Boolean then
|
|
|
|
return numbertoboolean(self:getU8())
|
2013-01-16 17:20:17 +01:00
|
|
|
elseif dataType == NetworkMessageTypes.U8 then
|
|
|
|
return self:getU8()
|
|
|
|
elseif dataType == NetworkMessageTypes.U16 then
|
|
|
|
return self:getU16()
|
|
|
|
elseif dataType == NetworkMessageTypes.U32 then
|
|
|
|
return self:getU32()
|
|
|
|
elseif dataType == NetworkMessageTypes.U64 then
|
2012-08-30 07:59:10 +02:00
|
|
|
return self:getU64()
|
2013-01-16 17:20:17 +01:00
|
|
|
elseif dataType == NetworkMessageTypes.NumberString then
|
|
|
|
return tonumber(self:getString())
|
2012-08-30 07:59:10 +02:00
|
|
|
elseif dataType == NetworkMessageTypes.String then
|
|
|
|
return self:getString()
|
|
|
|
elseif dataType == NetworkMessageTypes.Table then
|
|
|
|
return self:getTable()
|
|
|
|
else
|
|
|
|
perror('Unknown data type ' .. dataType)
|
|
|
|
end
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
function InputMessage:getTable()
|
|
|
|
local ret = {}
|
2013-01-16 17:20:17 +01:00
|
|
|
local size = self:getU16()
|
2012-08-30 07:59:10 +02:00
|
|
|
for i=1,size do
|
|
|
|
local index = self:getData()
|
|
|
|
local value = self:getData()
|
|
|
|
ret[index] = value
|
|
|
|
end
|
|
|
|
return ret
|
2013-01-16 17:20:17 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function InputMessage:getColor()
|
|
|
|
local color = {}
|
2013-01-30 22:08:43 +01:00
|
|
|
color.r = self:getU8()
|
|
|
|
color.g = self:getU8()
|
|
|
|
color.b = self:getU8()
|
|
|
|
color.a = self:getU8()
|
2013-01-16 17:20:17 +01:00
|
|
|
return color
|
|
|
|
end
|
2013-01-30 22:08:43 +01:00
|
|
|
|
|
|
|
function InputMessage:getPosition()
|
|
|
|
local position = {}
|
|
|
|
position.x = self:getU16()
|
|
|
|
position.y = self:getU16()
|
|
|
|
position.z = self:getU8()
|
|
|
|
return position
|
|
|
|
end
|