Template:O/doc: Difference between revisions

Template page
Line 24: Line 24:


p.main = function(frame) do
p.main = function(frame) do
   local standing = O.decode( frame.args.standing )
   local standing = O.decode( frame:getParent().args.standing )
   for k,v in pairs(standing)
   for k,v in pairs(standing)
     standing[k] = O.decode(v)
     standing[k] = O.decode(v)

Revision as of 09:56, 5 September 2023

This template encodes its arguments into JSON and then hex encodes the JSON. These arguments can then later be decoded by Module:O. This allows templates to use more complicated data structures for their arguments with ordinary wikitext syntax.

Usage

{{PunisherTable
  |standing={{o
    |{{o|frames=-10|id=Bryan-2,3}}
    |{{o|frames=-10|id=Bryan-1,4}}
  }}
  |crouching={{o
    |{{o|frames=-11|id=ws4}}
    |{{o|frames=-15|id=ws1|combo=?}}
  }}
}}

Later, in a Lua module called by {{PunisherTable}}:

local O = require("O")

p.main = function(frame) do
  local standing = O.decode( frame:getParent().args.standing )
  for k,v in pairs(standing)
    standing[k] = O.decode(v)
  end
end

Example

5b223762323236363732363136643635373332323361323232643331333032323263323236393634323233613232343237323739363136653264333232633333323237645c6e2020222c223762323236363732363136643635373332323361323232643331333032323263323236393634323233613232343237323739363136653264333132633334323237645c6e225d