lua-pb

lua-pb

A Protocol Buffer implementation that runs on World of Warcraft Addons. The lua-pb is based on the work of <https://github.com/Neopallium/lua-pb&gt; by Neopallium

Generate lua stub for your addon

  • install lpge

luarocks install lpeg

  • generate with saveast.lua

lua saveast.lua VARNAME &lt; FILE.proto &gt; STUB.lua

exmaple for using person.proto in wowtest folder lua saveast.lua pbperson &lt; person.proto &gt; wowtest/person.lua

Import in your addon

You have two choices to use lua-pb as a library

As files inside your addon

  1. Download relase zip from <https://www.wowace.com/projects/protobuf/files&gt;
  2. Copy lua-pb folder to your addon
  3. Add path\to\lua-pb\lua-pb.xml in your .toc file
  4. Add path\to\pbstub.lua in your .toc file

After loaded, lua-pb would be availiable in your addon ctx

Example (you can find exmaple in <wowtest/pb-wow-test.lua>)

``` local _, ADDONSELF = ...

local luapb = ADDONSELF.luapb local person = luapb.loadprotoast(ADDONSELF.pbperson).Person

local msg0 = person()

msg0.name = "aa" msg0.id = 1

print("serialize: name " .. msg0.name .. " id " .. msg0.id)

local t = msg0:Serialize()

assert(#t > 0, "size of t > 0")

local msg1 = person() msg1:Parse(t)

assert(msg1.name == msg0.name, "name not equal") assert(msg1.id == msg0.id, "id not equal")

print("deserialize: name " .. msg1.name .. " id " .. msg1.id)

```

Use as an dependency (Optional for LibStub)

local luapb = LibStub:GetLibrary('luapb')

Powered by lua-pb


Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    48866
  • Created
    Dec 23, 2012
  • Last Released File
    Oct 27, 2019
  • Total Downloads
    2,702
  • License

Categories

Members

Recent Files

WoW Retail