Module:Workarounds
From Fallen London Wiki (Staging)
Documentation for this module may be created at Module:Workarounds/doc
local p = {}
function p.seplist(frame)
local list = frame.args[1] .. '#'
local ret = ''
for s in string.gmatch(list, '(.-)#') do
ret = ret .. '*[[' .. s .. ']]\n'
end
return ret
end
function p.remove_templatestyles_artifacts(frame)
local text = frame.args[1]
text = mw.text.killMarkers(text)
text = mw.ustring.gsub(text, '%[%[Category:.-%]%]', '')
return text
end
function p.remove_categories(frame)
local text = frame.args[1]
text = mw.ustring.gsub(text, '%[%[Category:.-%]%]', '')
return text
end
function p.expand_rewards(frame)
local text = frame.args[1]
while true do
local reward_pos, reward_end = text:find('%(%(reward:%a*%)%)')
if reward_pos == nil then
break
end
local argument = text:sub(reward_pos + 9, reward_end - 2)
local reward_svg = frame:callParserFunction{
name = '#widget',
args = {
'FateRewardIcon',
t = string.lower(argument)
}
}
text = text:gsub('%(%(reward:' .. argument .. '%)%)', reward_svg)
end
text = mw.ustring.gsub(text, '%[%[Category:.-%]%]', '')
return text
end
function p.expand_link_from(frame)
local link = frame.args[1]
local from = tonumber(frame.args[2])
local s = '[[' .. link
for k, v in pairs(frame.args) do
if type(k) == 'number' then
if k >= 3 then
s = s .. '|' .. v
end
else
s = s .. '|' .. k .. '=' .. v
end
end
for k, v in pairs(frame:getParent().args) do
if type(k) == 'number' then
if k >= from then
s = s .. '|' .. v
end
else
s = s .. '|' .. k .. '=' .. v
end
end
return s .. ']]'
end
local p = {}
function p.smallify(image)
if mw.ustring.find(image, 'small.png') == nil then
image = mw.ustring.gsub(image, '.png', 'small.png')
end
return image
end
function p.seplist(frame)
local list = frame.args[1] .. '#'
local ret = ''
for s in string.gmatch(list, '(.-)#') do
ret = ret .. '*[[' .. s .. ']]\n'
end
return ret
end
function p.remove_templatestyles_artifacts(frame)
local text = frame.args[1]
text = mw.text.killMarkers(text)
text = mw.ustring.gsub(text, '%[%[Category:.-%]%]', '')
return text
end
function p.remove_categories(frame)
local text = frame.args[1]
text = mw.ustring.gsub(text, '%[%[Category:.-%]%]', '')
return text
end
function p.expand_rewards(frame)
local text = frame.args[1]
while true do
local reward_pos, reward_end = text:find('%(%(reward:%a*%)%)')
if reward_pos == nil then
break
end
local argument = text:sub(reward_pos + 9, reward_end - 2)
local reward_svg = frame:callParserFunction{
name = '#widget',
args = {
'FateRewardIcon',
t = string.lower(argument)
}
}
text = text:gsub('%(%(reward:' .. argument .. '%)%)', reward_svg)
end
text = mw.ustring.gsub(text, '%[%[Category:.-%]%]', '')
return text
end
function p.expand_link_from(frame)
local link = frame.args[1]
local from = tonumber(frame.args[2])
local s = '[[' .. link
for k, v in pairs(frame.args) do
if type(k) == 'number' then
if k >= 3 then
s = s .. '|' .. v
end
else
s = s .. '|' .. k .. '=' .. v
end
end
for k, v in pairs(frame:getParent().args) do
if type(k) == 'number' then
if k >= from then
s = s .. '|' .. v
end
else
s = s .. '|' .. k .. '=' .. v
end
end
return s .. ']]'
end
--[[
Get an argument passed to the module.
Input parameters:
@frame: frame object
@name: parameter name
If the parameter was no specified, or if it an empty string, return nil.
]]
function p.get_arg(frame, name)
local arg = frame.args[name] or frame:getParent().args[name]
if (arg == "") then arg = nil end
return arg
end
return p