repeat83

распаковка пакета

Feb 23rd, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1. require"pack"
  2. pkts = {}
  3. pkts.HRS = function(packet)
  4.   local self = {}
  5.   local _
  6.   self.unpack = function(...)
  7.     local _ = {...}; if (_[1] == self) then table.remove(_,1); end
  8.     local packet = unpack(_)
  9.     _, self.pkt, self.laps, self.quals = string.unpack(packet, "zbb")
  10.   end
  11.   return self
  12. end
  13.  
  14. p = "HRS\0"..string.char(20)..string.char(5)
  15. HRS = pkts.HRS(p)
  16. HRS.unpack(p)
  17. print(HRS.pkt, HRS.laps)
Advertisement
Add Comment
Please, Sign In to add comment