1,131
edits
No edit summary |
No edit summary |
||
| Line 286: | Line 286: | ||
ret:finish() | ret:finish() | ||
if onmain() then | |||
local a1 = ret:param('all') | |||
local a2 = ret:categoryData() | |||
ret:wikitext(addcategories(a1, a2)) | |||
end | |||
return ret:tostring() | return ret:tostring() | ||
end | |||
function addcategories(args, catargs) | |||
local ret = { 'Items' } | |||
local cat_map = { | |||
-- Added if the parameter has content | |||
defined = { | |||
aka = 'Pages with AKA' | |||
}, | |||
-- Added if the parameter has no content | |||
notdefined = { | |||
image = 'Needs image', | |||
release = 'Needs release date', | |||
id = 'Needs ID', | |||
description = 'Needs description', | |||
members = 'Needs members status', | |||
level = 'Needs level', | |||
cost = 'Items missing cost', | |||
sell = 'Items missing sell', | |||
value = 'Items missing value', | |||
quest = 'Items missing quest', | |||
}, | |||
-- Parameters that have text | |||
-- map a category to a value | |||
matches = { | |||
members = { yes = 'Members\' items', no = 'Free-to-play items' }, | |||
rune_tp = { yes = 'Runes'}, | |||
tradeable = { yes = 'Tradeable items', no = 'Untradeable items' }, | |||
} | |||
} | |||
-- defined categories | |||
for n, v in pairs(cat_map.defined) do | |||
if catargs[n] and catargs[n].one_defined then | |||
table.insert(ret, v) | |||
end | |||
end | |||
-- undefined categories | |||
for n, v in pairs(cat_map.notdefined) do | |||
if catargs[n] and catargs[n].all_defined == false then | |||
table.insert(ret, v) | |||
end | |||
end | |||
-- searches | |||
for n, v in pairs(cat_map.matches) do | |||
for m, w in pairs(v) do | |||
if args[n] then | |||
if string.lower(tostring(args[n].d) or '') == m then | |||
table.insert(ret, w) | |||
end | |||
if args[n].switches then | |||
for _, x in ipairs(args[n].switches) do | |||
if string.lower(tostring(x)) == m then | |||
table.insert(ret, w) | |||
end | |||
end | |||
end | |||
end | |||
end | |||
end | |||
-- quest items | |||
-- just look for a link | |||
if args.quest.d:find('%[%[') then | |||
table.insert(ret, 'Quest items') | |||
elseif args.quest.switches then | |||
for _, v in ipairs(args.quest.switches) do | |||
if v:find('%[%[') then | |||
table.insert(ret, 'Quest items') | |||
break | |||
end | |||
end | |||
end | |||
-- ids | |||
if not catargs.id.all_defined then | |||
table.insert(ret, 'Needs ID') | |||
end | |||
-- combine table and format category wikicode | |||
for i, v in ipairs(ret) do | |||
ret[i] = string.format('[[Category:%s]]', v) | |||
end | |||
return table.concat(ret, '') | |||
end | end | ||
return p | return p | ||