Module:Icons: Difference between revisions

1,188 bytes added ,  29 October 2022
Adding typeImgOverrides and CSS classes (imgClassOverrides), and adding Township resources and stats
(Add type "township")
(Adding typeImgOverrides and CSS classes (imgClassOverrides), and adding Township resources and stats)
Line 171: Line 171:
local typeExtOverrides = {
local typeExtOverrides = {
-- Example: ["item"] = { ["Chicken"] = "png" }
-- Example: ["item"] = { ["Chicken"] = "png" }
}
}


--When calling for an icon of type Key, instead use type Value
--When calling for an icon of type Key, instead use type Value
Line 243: Line 243:
['Generous Harvest Potion'] = {'Generous Harvest Potion I', 'item'},
['Generous Harvest Potion'] = {'Generous Harvest Potion I', 'item'},
['Seeing Gold Potion'] = {'Seeing Gold Potion I', 'item'},
['Seeing Gold Potion'] = {'Seeing Gold Potion I', 'item'},
-- Township resources
['GP'] = {'Coins', ''},
['Food'] = {'Raw Beef', 'item'},
['Ore'] = {'Iron', 'rock'},
['Bar'] = {'Iron Bar', 'item'},
['Herbs'] = {'Garum Herb', 'item'},
['Clothing'] = {'Leather Body', 'item'},
-- Easter egg stuff
-- Easter egg stuff
["Lemonade (Empty)"] = "Lemonade",
["Lemonade (Empty)"] = "Lemonade",
Line 274: Line 281:
["Lemonade (Wait for it!)"] = "Lemonade",
["Lemonade (Wait for it!)"] = "Lemonade",
["Lemonade (Full)"] = "Lemonade"
["Lemonade (Full)"] = "Lemonade"
}
--When calling for an icon for Key + Type, replace with image Value, and optionally override type also
local typeImgOverrides = {
['resource'] = {
['Rune Essence'] = {'Rune Essence', 'item'},
['Leather'] = {'Leather', 'item'},
}
}
}
--When calling for an icon for Key, the link goes to Value
--When calling for an icon for Key, the link goes to Value
Line 300: Line 314:
['Siren'] = true,
['Siren'] = true,
['Lightning Spirit'] = true,
['Lightning Spirit'] = true,
}
--When calling for an icon for Key, add a css class
local imgClassOverrides = {
-- Township Stat Icons are licensed from Font Awesome Free 5.14.0 under CC BY 4.0 (https://github.com/FortAwesome/Font-Awesome/tree/5.14.0)
['Population'] = 'township-colortoggle',
['Workers'] = 'township-colortoggle',
['Storage'] = 'township-colortoggle',
}
}


Line 315: Line 336:
local qty = args.qty
local qty = args.qty
local img = args.img ~= nil and args.img ~= '' and args.img or link
local img = args.img ~= nil and args.img ~= '' and args.img or link
local class = args.class ~= nil and args.class ~= '' and args.class or ''


link = fixPagename(link)
link = fixPagename(link)
Line 326: Line 348:
--MANUAL OVERRIDES
--MANUAL OVERRIDES
local ovrImg = imgOverrides[link]
local ovrImg = imgOverrides[link]
local ovrTypeImg = typeImgOverrides[iconType]
if ovrTypeImg ~= nil then
ovrImg = ovrTypeImg ~= nil and ovrTypeImg[img] or ovrImg
end
local ovrTxt = txtOverrides[link]
local ovrTxt = txtOverrides[link]
local ovrLink = linkOverrides[link]
local ovrLink = linkOverrides[link]
Line 337: Line 363:
end
end
end
end
local ovrClass = imgClassOverrides[link]
-- Type & extension overrides must be after adjustments have been made
-- Type & extension overrides must be after adjustments have been made
-- for any image overrides
-- for any image overrides
Line 367: Line 394:
iconType = ovrType
iconType = ovrType
end
end
if ovrClass ~= nil then
class = ovrClass
end
class = class ~= nil and class ~= '' and ' class="'..class..'"' or ''
-- There are a couple specific double overrides to be included that don't fit in the above lists
-- There are a couple specific double overrides to be included that don't fit in the above lists
if ambiguousOverrides[link] then
if ambiguousOverrides[link] then
Line 404: Line 435:
return '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|' .. resultText .. '\r\n|}'
return '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|' .. resultText .. '\r\n|}'
elseif not noicon then
elseif not noicon then
return '<span style="display:inline-block">' .. resultText .. '</span>'
return '<span style="display:inline-block"'..class..'>' .. resultText .. '</span>'
else
else
return resultText
return resultText
572

edits