ARK: Survival Evolved Wiki
(created)
 
No edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 2: Line 2:
   
 
function p.distinguish(frame)
 
function p.distinguish(frame)
local template = frame.args[1]
+
local template = frame.args[1]
 
local args = frame:getParent().args
 
local args = frame:getParent().args
  +
local noDlcIcon = args.noDlcIcon or ''
 
local links = {}
 
local links = {}
for i, v in ipairs(args) do
+
for i, v in ipairs(args) do
 
local s = trim(args[i])
 
local s = trim(args[i])
 
if #s > 0 then
 
if #s > 0 then
table.insert(links, frame:expandTemplate{title = template, args = { s } })
+
table.insert(links, frame:expandTemplate{title = template, args = { s, noDlcIcon = noDlcIcon } })
 
end
 
end
 
end
 
end
  +
 
  +
if args[2] ~= nil and args[3] == nil then
return mw.text.listToText( links, ', ', ', or ' )
 
  +
return mw.text.listToText( links, ', ', ' or ' )
  +
else
 
return mw.text.listToText( links, ', ', ', or ' )
 
end
 
end
 
end
   

Latest revision as of 14:22, 27 May 2020

Template-info Documentation

This is a helper module for Template:Distinguish.


local p = {}

function p.distinguish(frame)
    local template = frame.args[1]
    local args = frame:getParent().args
    local noDlcIcon = args.noDlcIcon or ''
    local links = {}
    for i, v in ipairs(args) do 
        local s = trim(args[i])
        if #s > 0 then
            table.insert(links, frame:expandTemplate{title = template, args = { s, noDlcIcon = noDlcIcon } })
        end
    end

    if args[2] ~= nil and args[3] == nil then    
        return mw.text.listToText( links, ', ', ' or ' )
    else
        return mw.text.listToText( links, ', ', ', or ' )
    end
end

function trim(s)
   return (s:gsub("^%s*(.-)%s*$", "%1"))
end

return p