WoW lua-pb addon Shadowlands/classic 2020
logo
wow addon lua-pb

lua-pb

Game Version: 8.2.5
Total Downloads: 1,910
Updated: Oct 27, 2019
Created: Dec 23, 2012
download lua-pbDownload Earlier Versions

Earlier Versions

Name Size Uploaded Game Version Downloads
v1.1.0 release 24.72 KB Oct 27, 2019 8.2.5 218 download lua-pb v1.1.0 releaseDownload

Description

Share this:

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

  • Myslot

Comments

Add a comment