Final Fantasy Wiki
Explore
Main Page
Discuss
All Pages
Community
Interactive Maps
VII Rebirth
Characters
Cloud Strife
Tifa Lockhart
Aerith Gainsborough
Barret Wallace
Red XIII
Yuffie Kisaragi
Cait Sith
Cid Highwind
Vincent Valentine
Zack Fair
Locations
Kalm
Junon
Costa del Sol
Gold Saucer
Gongaga
Cosmo Canyon
Nibelheim
Other latest & upcoming games
Final Fantasy XVI
Final Fantasy XIV: Dawntrail
Games
Final Fantasy I - VIII
Final Fantasy
Final Fantasy II
Final Fantasy III
Final Fantasy IV
Final Fantasy V
Final Fantasy VI
Final Fantasy VII
Final Fantasy VIII
Final Fantasy IX - XVI
Final Fantasy IX
Final Fantasy X
Final Fantasy XI
Final Fantasy XII
Final Fantasy XIII
Final Fantasy XIV
Final Fantasy XV
Final Fantasy XVI
Subseries
Contents
Characters
Jobs
Races
Locations
Gameplay
Items
Equipment
Abilities
Magic
Enemies
Bosses
Music
Walkthroughs
Community
Administrators & staff directory
Contact us
Wiki business and feedback
Discord chat
Staff Noticeboard
Wiki editor portal
Policies and guidelines
Scope
Recent Changes
All logs
Wiki projects
Maintenance
Create article
Upload files
Let's Play
Podcast
Social media
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Final Fantasy Wiki
49,209
pages
Explore
Main Page
Discuss
All Pages
Community
Interactive Maps
VII Rebirth
Characters
Cloud Strife
Tifa Lockhart
Aerith Gainsborough
Barret Wallace
Red XIII
Yuffie Kisaragi
Cait Sith
Cid Highwind
Vincent Valentine
Zack Fair
Locations
Kalm
Junon
Costa del Sol
Gold Saucer
Gongaga
Cosmo Canyon
Nibelheim
Other latest & upcoming games
Final Fantasy XVI
Final Fantasy XIV: Dawntrail
Games
Final Fantasy I - VIII
Final Fantasy
Final Fantasy II
Final Fantasy III
Final Fantasy IV
Final Fantasy V
Final Fantasy VI
Final Fantasy VII
Final Fantasy VIII
Final Fantasy IX - XVI
Final Fantasy IX
Final Fantasy X
Final Fantasy XI
Final Fantasy XII
Final Fantasy XIII
Final Fantasy XIV
Final Fantasy XV
Final Fantasy XVI
Subseries
Contents
Characters
Jobs
Races
Locations
Gameplay
Items
Equipment
Abilities
Magic
Enemies
Bosses
Music
Walkthroughs
Community
Administrators & staff directory
Contact us
Wiki business and feedback
Discord chat
Staff Noticeboard
Wiki editor portal
Policies and guidelines
Scope
Recent Changes
All logs
Wiki projects
Maintenance
Create article
Upload files
Let's Play
Podcast
Social media
Editing
Module:Icon
Back to page
Edit source
View history
Talk (0)
Edit Page
Module:Icon
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- <nowiki> local p = {} local getArgs = require('Dev:Arguments').getArgs -------------- CONSTANTS -------------- -- The value of these constants don't matter, except that it cannot equal the name of an article on the FFWiki local LOADER_FLAG = 30071996 local ERROR_FLAG = 23061914 -- Every entry here should either be the URL of a game's data table directory or LOADER_FLAG -- If it is LOADER_FLAG, the game needs a loader (see the next section) -- LOADER_FLAG should be used for games with very large data tables to cut down on load times and memory usage local GAMES = { ["ffvi"] = "Module:Icon/data/FFVI/", ["ffviir"] = "Module:Icon/data/FFVIIR/", ["ffviir2"] = "Module:Icon/data/FFVIIR2/", ["woff"] = "Module:Icon/data/WoFF/", ["ffbe"] = "Module:Icon/data/FFBE/", ["ffxiv"] = LOADER_FLAG, } -- Some more constants used by loaders local FFXIV_DIRECTORY = "Module:Icon/data/FFXIV/" local FFXIV_ITEM_CATEGORIES = "Module:Icon/data/FFXIV/Item Categories" -------------- LOADERS -------------- -- Loaders for specific games (these are only necessary for games with FUNCTION_FLAG) -- A loader is a function that takes (category, icon) and returns the associated data table while NOT loading any other data table. -- Example: loaderz["ffxiv"]("quests", "la-hee") == mw.loadData("Module:Icon/data/FFXIV/Quests")["la-hee"] -- This is necessary for games with very large data tables, or with data tables. -- Loaders can also be used to call databases other than Module:Icon/data. local loaderz = {} -- loaders is a magic word in Lua, lol loaderz["ffxiv"] = function(category, icon) if category == "Item" then -- This case WILL be scrapped once we have XIVAPI integration, as it causes serious performance issues. local ffxiv_item_types = mw.loadData(FFXIV_ITEM_CATEGORIES) for _, item_type in ipairs(ffxiv_item_types) do local d = mw.loadData(FFXIV_DIRECTORY .. item_type) if d[icon] then return d[icon] end end elseif category == "Minion" then return loaderz["ffxiv"]("Minion Item", icon) elseif category == "Achievement" then local x = mw.loadData("Module:XIVAPI/Achievements")[1][icon] or {} return { ["file"] = x.icon or '', ["link"] = ("Final Fantasy XIV achievements#" .. x.name:gsub(" ", "_")) or icon, ["name"] = x.name or icon } else return mw.loadData(FFXIV_DIRECTORY .. category)[icon] end end function load(game, category, icon) return ((GAMES[game] == LOADER_FLAG) and loaderz[game](category, icon)) or ((not (GAMES[game] == LOADER_FLAG)) and mw.loadData(GAMES[game] .. category)[icon]) or ERROR_FLAG end -------------- METHODS -------------- -- Implements {{Icon|1=game|2=category|3=icon}} function p.main(frame) local args = getArgs(frame) local game = assert(args.game or args[1], 'Game icons not found') local category = assert(args.category or args[2], 'Category not found') local icon = assert(args.icon or args[3], 'Icon not found') -- Enforce capitalization conventions. -- game and icon must be lowercase -- category must have the first letter of each word capitalized, and all other letters lowercase -- category trick stolen from https://stackoverflow.com/questions/20284515/capitalize-first-letter-of-every-word-in-lua game = game:lower() category = string.gsub(category, "(%a)([%w_']*)", function(first, rest) return first:upper() .. rest:lower() end) icon = icon:lower() local ico = load(game, category, icon) if (ico == ERROR_FLAG) then local cout = args.icon or args[3] -- going back to args overturns capitalization conventions if cout then return '[[' .. cout .. ']]' else return '' end end local file = ((ico.shadowed and '<span class="shadowed-icon">') or '') .. '[[File:' .. ico.file .. '|alt=' .. ico.name .. '|15px|link=' .. (ico.link or '') .. ']]' .. ((ico.shadowed and '</span>') or '') local link = '' if ico.link and not (args[4] == 'nolink') then link = ' [[' .. ico.link .. '|' .. ico.name .. ']]' end return file .. link end -- Returns a gallery of everything in a category -- This is usually huge and therefore useless in mainspace -- Its main purpose is as a hack to avoid Special:UnusedFiles fuckery -- game needs to be as in the wiki page name (WoFF, not woff) function p.gallery(frame) local args = getArgs(frame) local game = assert(args.game or args[1], 'Game icons not found') local category = assert(args.category or args[2], 'Category not found') category = string.gsub(category, "(%a)([%w_']*)", function(first, rest) return first:upper() .. rest:lower() end) local s = "" for _, v in pairs(mw.loadData("Module:Icon/data/" .. game .. "/" .. category)) do s = s .. "* [[File:" .. v.file .. "|" .. v.name .. "]]\n" end return s end return p -- </nowiki>
Summary:
Please note that all contributions to the Final Fantasy Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Tl
(
view source
)
Module:Icon/doc
(
edit
)
Module:Tl
(
edit
)
Module:Tl/data
(
edit
)
Follow on IG
TikTok
Join Fan Lab