Flower Knight Girl Wikia
Advertisement
Flower Knight Girl Wikia

Documentation for this module may be created at Module:Artists/doc

--[[Category:Character description modules]]
-- Relates characters and artists.

local p = {}
local get_args = require("Module:Arguments").getArgs

------------------------------
-- Functions accessed from templates.
------------------------------

-- Gets the text for the character template to show the artist.
function p.get_artist_for_character_page(frame)
    local args = get_args(frame:getParent())
    return p._get_artist_for_character_page(args)
end

-- Gets the character's artist.
function p.get_artist(frame)
    local args = get_args(frame:getParent())
    return p._get_artist(args)
end

------------------------------
-- Misc functions and helper functions for those called by templates.
------------------------------

--[[ Loads a module if it hasn't been loaded yet.
@arg mod_name: String. The name of the module without the "Module:" part.
@returns True if the module was loaded for the first time.
    False if the module was already available.
--]]
function p.__load_module(mod_name)
    if not p[mod_name] then
        p[mod_name] = require('Module:' .. mod_name)
        return true
    end
    return false
end

------------------------------
-- Functions called indirectly by templates.
------------------------------

--[[ Gets a character's artist's info for the individual character pages.
@arg args[1]: String. The character's Japanese name.
@returns String. The artist on success, or an emptry string on failure.
--]]
function p._get_artist(args)
    p.__load_module("Artists/Data")
    return p['Artists/Data']['artist_by_char'][args[1]] or ""
end

--[[ Gets a character's artist's info for the individual character pages.
@arg args[1]: String. The character's Japanese name.
@returns String. The artist and their affiliated category.
--]]
function p._get_artist_for_character_page(args)
    local artist_name = p._get_artist(args)
    if artist_name == "" then
        -- No artist assigned to this character.
        return ""
    else
        -- Create the final output.
        --<nowiki>
        return string.format('%s[[Category:Artist:%s]]', artist_name, artist_name)
        --</nowiki>
    end
end

return p
Advertisement