Module:Link: Difference between revisions
Jump to navigation
Jump to search
Create: Minecraft Mod Wiki>Joker876 Created page with "local p = {} function p.mcWikiLink (f) local origArgs = f if f == mw.getCurrentFrame() then origArgs = f:getParent().args else f = mw.getCurrentFrame() end local arg..." |
BoxWithout (talk | contribs) Undo revision 36223 by BoxWithout (talk) Didn't work. Tag: Undo |
||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local vanillaPages = mw.loadData('Module:Link/VanillaPages') | |||
function p.mcWikiLink (f) | function p.mcWikiLink (f) | ||
Line 17: | Line 19: | ||
local alt = args[2] or link | local alt = args[2] or link | ||
if not link then return '[[w: | if vanillaPages[link] then return table.concat{'[[', link, '|', alt, ']]'} end | ||
if not link then return '[https://mine'..'craft.wiki <span title="Minecraft Wiki">Minecraft Wiki</span>]' end | |||
return table.concat{ | |||
'[https://mine'..'craft.wiki/w/', string.gsub(link, " ", "_"), ' <span title="Minecraft Wiki: ', link, '">', alt, '</span>]' | |||
} | |||
end | |||
function p.githubLink (f) | |||
local origArgs = f | |||
if f == mw.getCurrentFrame() then | |||
origArgs = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
local args = {} | |||
for k,v in pairs(origArgs) do | |||
if type(k) == "string" then k = k:lower() end | |||
args[k] = v | |||
end | |||
local link = args[1] | |||
local alt = args[2] or link | |||
if not link then return '[https://github.com/Creators-of-Create/Create/wiki/ <span title="Github Wiki">Github Wiki</span>]' end | |||
return table.concat{ | return table.concat{ | ||
'[ | '[https://github.com/Creators-of-Create/Create/wiki/', string.gsub(link, " ", "-"), ' ', alt, ']' | ||
} | } | ||
end | end | ||
return p | return p |
Latest revision as of 13:54, 18 February 2025
Documentation for this module may be created at Module:Link/doc
local p = {}
local vanillaPages = mw.loadData('Module:Link/VanillaPages')
function p.mcWikiLink (f)
local origArgs = f
if f == mw.getCurrentFrame() then
origArgs = f:getParent().args
else
f = mw.getCurrentFrame()
end
local args = {}
for k,v in pairs(origArgs) do
if type(k) == "string" then k = k:lower() end
args[k] = v
end
local link = args[1]
local alt = args[2] or link
if vanillaPages[link] then return table.concat{'[[', link, '|', alt, ']]'} end
if not link then return '[https://mine'..'craft.wiki <span title="Minecraft Wiki">Minecraft Wiki</span>]' end
return table.concat{
'[https://mine'..'craft.wiki/w/', string.gsub(link, " ", "_"), ' <span title="Minecraft Wiki: ', link, '">', alt, '</span>]'
}
end
function p.githubLink (f)
local origArgs = f
if f == mw.getCurrentFrame() then
origArgs = f:getParent().args
else
f = mw.getCurrentFrame()
end
local args = {}
for k,v in pairs(origArgs) do
if type(k) == "string" then k = k:lower() end
args[k] = v
end
local link = args[1]
local alt = args[2] or link
if not link then return '[https://github.com/Creators-of-Create/Create/wiki/ <span title="Github Wiki">Github Wiki</span>]' end
return table.concat{
'[https://github.com/Creators-of-Create/Create/wiki/', string.gsub(link, " ", "-"), ' ', alt, ']'
}
end
return p