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 = {}
|
|
|
|
color.r = msg:getU8()
|
|
|
|
color.g = msg:getU8()
|
|
|
|
color.b = msg:getU8()
|
|
|
|
color.a = msg:getU8()
|
|
|
|
return color
|
|
|
|
end
|