1-- automatically generated by the FlatBuffers compiler, do not modify 2 3-- namespace: Sample 4 5local flatbuffers = require('flatbuffers') 6 7local Weapon = {} -- the module 8local Weapon_mt = {} -- the class metatable 9 10function Weapon.New() 11 local o = {} 12 setmetatable(o, {__index = Weapon_mt}) 13 return o 14end 15function Weapon.GetRootAsWeapon(buf, offset) 16 local n = flatbuffers.N.UOffsetT:Unpack(buf, offset) 17 local o = Weapon.New() 18 o:Init(buf, n + offset) 19 return o 20end 21function Weapon_mt:Init(buf, pos) 22 self.view = flatbuffers.view.New(buf, pos) 23end 24function Weapon_mt:Name() 25 local o = self.view:Offset(4) 26 if o ~= 0 then 27 return self.view:String(o + self.view.pos) 28 end 29end 30function Weapon_mt:Damage() 31 local o = self.view:Offset(6) 32 if o ~= 0 then 33 return self.view:Get(flatbuffers.N.Int16, o + self.view.pos) 34 end 35 return 0 36end 37function Weapon.Start(builder) builder:StartObject(2) end 38function Weapon.AddName(builder, name) builder:PrependUOffsetTRelativeSlot(0, name, 0) end 39function Weapon.AddDamage(builder, damage) builder:PrependInt16Slot(1, damage, 0) end 40function Weapon.End(builder) return builder:EndObject() end 41 42return Weapon -- return the module