- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Module:Artist
Revision as of 07:24, 3 August 2016 by com>Ckwng (Created page with "local Artist = {} local artists = {} local ArtistData = require('Module:ArtistData') function Artist:get(stat, name) return self:create(name)[stat]() end function Artist:...")
Documentation for this module may be created at Module:Artist/doc
local Artist = {}
local artists = {}
local ArtistData = require('Module:ArtistData')
function Artist:get(stat, name)
return self:create(name)[stat]()
end
function Artist:create(name)
if name == nil then
return ArtistData()
--check if we already have it
elseif artists[name] then
return artists[name]
else
--Catch a failed require
local success, artist_table = pcall(function () return require(self:get_module(name)) end)
--require failed
if not success then
--create a ArtistData with what we have
artist_table = {_name = name}
end
local artist = ArtistData(artist_table)
artists[name] = artist
return artist
end
end
function Artist:get_module(name)
if name == nil then
return nil
end
return mw.ustring.format('Module:Artist/%s', name)
end
function Artist:extend(data)
data = data or {}
setmetatable(data, data)
data.__index = self
data.__call = self.__call
return data
end
Artist.__call = Artist.create
setmetatable(Artist, Artist)
return Artist