Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

For the second question, see Extract field values example on the wiki:

...
  57         -- extract the field into a table of FieldInfos
  58         finfos = { field() }
  59
  60         if #finfos > 0 then
  61             -- add our proto if we haven't already
  62             if not tree then
  63                 tree = root:add(exproto)
  64             end
  65
  66             for _, finfo in ipairs(finfos) do
...

The EASYPOST.lua script wiki:lua#examples does something similar.
This allows processing all instances of a field in a packet.

    -- copy existing field(s) into table for processing
    finfo = { easypost_payload_f() }

    if (#finfo > 0) then
        if not subtree then
            subtree = tree:add(easypost_p)
        end
        for k, v in pairs(finfo) do