モジュール:DinoIcon
ナビゲーションに移動
検索に移動
このモジュールについての説明文ページを モジュール:DinoIcon/doc に作成できます
-- https://ark.wiki.gg/wiki/Module:DinoIcon 10:06, 8 October 2022
local p = {}
local Utility = require( 'Module:Utility' )
local Bindings = {
['Aberrant Creatures'] = 'aberrant',
['Alpha Creatures'] = 'alpha',
['Brute Creatures'] = 'brute',
['Corrupted Creatures'] = 'corrupt',
['Enraged Creatures'] = 'enraged',
['Event Creatures'] = 'event',
['Malfunctioned Tek Creatures'] = 'mtek',
['R-Creatures'] = 'r',
['Tek Creatures'] = 'tek',
['VR Creatures'] = 'vr',
['X-Creatures'] = 'x',
}
local Enable = false
local AllowIconOverrides = false
local UseDynamicResolution = true
local Pregenerated = nil -- mw.loadData( 'Module:DinoIcon/pregenerated' )
function p.resolveStatic( creature )
local result = Pregenerated[creature]
if result == true then
result = { 'dinolink', creature }
end
return result
end
function p.resolveDynamic( creature )
local data = Utility.runCachedCargoQuery( 'DinoIconMetadata', {
expiryTime = 60 * 30,
inProcess = true,
tableName = 'Entities',
fields = 'Article, VariantOf, Groups',
key = 'Article',
options = {
limit = 9999
}
} )
local row = data[creature]
if row then
if row.VariantOf then
if AllowIconOverrides and Utility.doesFileExist( creature .. '.png' ) then
return { 'dinolink', creature }
end
for group, class in pairs( Bindings ) do
if row.Groups:find( group, nil, true ) then
return { 'dinolink dinolink--' .. class, row.VariantOf }
end
end
end
return { 'dinolink', creature }
end
return nil
end
function p.resolve( creature )
if not Enable then
return nil
end
local result = -2
if Pregenerated ~= nil then
result = p.resolveStatic( creature )
end
if result == -2 and UseDynamicResolution then
result = p.resolveDynamic( creature )
end
if result == -2 then
result = nil
end
return result
end
return p