Difference between revisions of "Module:LinkUtils"
BryghtShadow (talk | contribs) m |
|||
Line 9: | Line 9: | ||
end |
end |
||
− | function p.acdbLink(iname) |
+ | function p.acdbLink(iname, jp) |
local prefix = string.sub(iname, 1, 2) |
local prefix = string.sub(iname, 1, 2) |
||
Line 19: | Line 19: | ||
local url = 'http://www.alchemistcodedb.com/' |
local url = 'http://www.alchemistcodedb.com/' |
||
+ | |||
+ | if jp then |
||
+ | url = url..'jp/' |
||
+ | end |
||
if type then |
if type then |
Revision as of 01:53, 16 January 2021
Documentation for this module may be created at Module:LinkUtils/doc
local p = {}
function p.wikiSafeName(name)
if name == nil then return end
return string.gsub(name, '[%[%]]', {
['['] = '【',
[']'] = '】',
})
end
function p.acdbLink(iname, jp)
local prefix = string.sub(iname, 1, 2)
local type = (prefix == 'IT' and 'item') or (prefix == 'TS' and 'card') or (prefix == 'AF' and 'gear') or (prefix == 'QE' and 'quest') or (prefix == 'UN' and 'unit') or nil
if type == 'unit' then
iname = string.gsub(iname, 'UN_V2_', '')
end
local url = 'http://www.alchemistcodedb.com/'
if jp then
url = url..'jp/'
end
if type then
url = url..type..'/'..string.lower(string.gsub(iname, '_', '-'))
end
return url
end
return p