Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | -- automatically generated by the FlatBuffers compiler, do not modify |
| 2 | |
| 3 | -- namespace: Sample |
| 4 | |
| 5 | local flatbuffers = require('flatbuffers') |
| 6 | |
| 7 | local Weapon = {} -- the module |
| 8 | local Weapon_mt = {} -- the class metatable |
| 9 | |
| 10 | function Weapon.New() |
| 11 | local o = {} |
| 12 | setmetatable(o, {__index = Weapon_mt}) |
| 13 | return o |
| 14 | end |
| 15 | function 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 |
| 20 | end |
| 21 | function Weapon_mt:Init(buf, pos) |
| 22 | self.view = flatbuffers.view.New(buf, pos) |
| 23 | end |
| 24 | function 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 |
| 29 | end |
| 30 | function 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 |
| 36 | end |
| 37 | function Weapon.Start(builder) builder:StartObject(2) end |
| 38 | function Weapon.AddName(builder, name) builder:PrependUOffsetTRelativeSlot(0, name, 0) end |
| 39 | function Weapon.AddDamage(builder, damage) builder:PrependInt16Slot(1, damage, 0) end |
| 40 | function Weapon.End(builder) return builder:EndObject() end |
| 41 | |
| 42 | return Weapon -- return the module |