Difference between revisions of "Module:Changes"

From Industrial-Craft-Wiki
Jump to navigation Jump to search
m (Allowed wiki changes to be shown using the same template)
m (Removed the word "wiki" for wiki changes)
Line 26: Line 26:
   end
   end
   if mw.ustring.find(args["version"], "wiki") ~= nil then
   if mw.ustring.find(args["version"], "wiki") ~= nil then
       back = "'''Wiki v" .. args["version"] .. ":'''" .. back
       back = "'''Wiki v" .. string.sub(args["version"], 6) .. ":'''" .. back
   else
   else
       if args["IC²"] ~= nil then
       if args["IC²"] ~= nil then

Revision as of 19:06, 12 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 = {}

-- Generate list
function p.list( args )
   local s = nil
   local n = 1
   local back = "<ul>" --"Arguments <br/><ul>"

   repeat s = args["change" .. n]
      if s ~= nil then
         back = back .. "<li>" .. s .. "</li>"
         n = n + 1
      end
   until s == nil

   return back .. "</ul>"
end

function p.changes( f )
   if f == mw.getCurrentFrame() then
       args = f:getParent().args
   end
   back = p.list(args)
   if args["version"] == nil then
      args["version"] = ""
   end
   if mw.ustring.find(args["version"], "wiki") ~= nil then
      back = "'''Wiki v" .. string.sub(args["version"], 6) .. ":'''" .. back
   else
      if args["IC²"] ~= nil then
         back = "'''IC² v" .. args["version"] .. ":'''" .. back
      else
         back = "'''IC v" .. args["version"] .. ":'''" .. back
      end
      if mw.ustring.find(args["version"], "2.*") ~= nil then
         back = back .. "<br/>[[Updates#v" .. args["version"] .. "|'''Read More''']]"
      elseif args["readmore"] ~= nil then
         if args["IC²"] ~= nil then
            back = back .. "<br/>[[Updates/IC2#v" .. args["version"] .. ".C2.A0.28IC.C2.B2.29|'''Read More''']]"
         else
            back = back .. "<br/>[[Updates/IC#v" .. args["version"] .. "|'''Read More''']]"
         end
      end
      if args["download"] ~= nil then
         back = back .. "<br/>[[Download#Download|'''Download Now''']]"
      end
   end
   if args["notlast"] ~= nil then
      back = back .. "<br/><hr style=\"width:auto;\"><br/>"
   end
   return back
end

return p