Difference between revisions of "Module:Changes"

From Industrial-Craft-Wiki
Jump to navigation Jump to search
m (This'd give it some stucture)
m (Rewriting)
Line 2: Line 2:


-- Changes
-- Changes
function p.changes()
function p.changes( f )
  local args = f
   local groups = {}
   local groups = {}
   local n = 1
   local n = 1
   local s = nil
   local s = nil
   if mw.getCurrentFrame().args["change" .. n] ~= nil then
 
      repeat s = mw.getCurrentFrame().args["change" .. n]
   if f == mw.getCurrentFrame() then
        groups[n] = "<li>" .. s .. "</li>"
      args = f:getParent().args
      until not s
   end
   end
  repeat s = args["change" .. n]
      groups[n] = "<li>" .. s .. "</li>"
  until not s
   local back = "Arguments <br/>"
   local back = "Arguments <br/>"
   for key,value in pairs(groups) do  
   for key,value in pairs(groups) do  

Revision as of 18:40, 9 February 2015

Template-info.png Documentation

Replacement Lua scripting to do what Template:Changes does/did, but in a more flexible way.

  • It supports the new structure of Version History.
  • It can have as many changes as needed, providing that they go up sequencially, and numbers are not missed out (change1, change2, change3 is ok, but change1, change3 isn't).
  • It should be faster.

Message me (Chocohead) either on the wiki (here) or on the Forum if you find any problems.

The above documentation is transcluded from Module:Changes/doc. (edit | history)


local p = {}

-- Changes
function p.changes( f )
   local args = f
   local groups = {}
   local n = 1
   local s = nil

   if f == mw.getCurrentFrame() then
       args = f:getParent().args
   end
 
   repeat s = args["change" .. n]
      groups[n] = "<li>" .. s .. "</li>"
   until not s

   local back = "Arguments <br/>"
   for key,value in pairs(groups) do 
      back = back .. value .. "<br/>"
   end
   return back
end

return p