Module:MCColor: Difference between revisions
Jump to navigation
Jump to search
(returning to a previous state) Tag: Manual revert |
(testing some theory will revert afterwards) Tag: Reverted |
||
Line 20: | Line 20: | ||
local args = frame.args | local args = frame.args | ||
local mccolor = preprocessArg(args[1]) | local mccolor = preprocessArg(args[1]) | ||
local wikicolor = preprocessArg(args[2]) | |||
-- Check for blank mccolor arguments | -- Check for blank mccolor arguments | ||
Line 31: | Line 32: | ||
return '' | return '' | ||
else | else | ||
return MCColorData.wikicolor or '' | --return MCColorData.wikicolor or '' | ||
if wikicolor then | |||
return MCColorData[wikicolor] or '' | |||
else | |||
return '' | |||
end | |||
end | end | ||
end | end | ||
return p | return p |
Revision as of 13:30, 19 February 2024
text
local data = mw.loadData('Module:MCColor/data') local p = {} --[ Thecow275's MC-Color Module V2]-- -- Trim whitespace from args, and treat blank args as nil local function preprocessArg(s) if not s then return nil end s = s:match('^%s*(.-)%s*$') -- trim whitespace if s == '' then return nil else return s end end function p.main(frame) local args = frame.args local mccolor = preprocessArg(args[1]) local wikicolor = preprocessArg(args[2]) -- Check for blank mccolor arguments if not mccolor then return '' end -- Get the data for the specified mccolor local MCColorData = data[mccolor] if not MCColorData then return '' else --return MCColorData.wikicolor or '' if wikicolor then return MCColorData[wikicolor] or '' else return '' end end end return p