🌟 | 現在、 鉄壁ヘッドショットには対応済みです。 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「モジュール:Utility/ImageWithName」の版間の差分
ナビゲーションに移動
検索に移動
(ホップアップのリンク設定を「nil → デフォルト」、「値あり → そのまま」、「空 → なし」と分岐できるように変更) |
(装備品の関数が正しく呼び出せなくなっていた問題の修正) |
||
(同じ利用者による、間の4版が非表示) | |||
1行目: | 1行目: | ||
local p = {} | local p = {} | ||
local cfg = mw.loadData('Module:Utility/ImageWithName/configuration') | local cfg = mw.loadData('Module:Utility/ImageWithName/configuration') | ||
local aw = require('Module:Utility/Library') | |||
local function buildClasses(opts) | local function buildClasses(opts) | ||
24行目: | 26行目: | ||
if link then | if link then | ||
if link ~= '' then | if link ~= '' then | ||
linkString = name | |||
else | |||
return string.format('%%s %s', cfg.format), link | return string.format('%%s %s', cfg.format), link | ||
end | end | ||
else | else | ||
37行目: | 39行目: | ||
local nu = require('Module:Utility/Name') | local nu = require('Module:Utility/Name') | ||
local function getSimpleResource(key, id, opts, imagefunc, namefunc | local function getSimpleResource(key, id, opts, imagefunc, namefunc) | ||
opts = opts or { lang = 'ja' } | opts = opts or { lang = 'ja' } | ||
opts.lang = opts.lang or 'ja' | opts.lang = opts.lang or 'ja' | ||
43行目: | 45行目: | ||
local classes = buildClasses(opts) | local classes = buildClasses(opts) | ||
local name = namefunc(id, opts.lang) | local name = namefunc(id, opts.lang) | ||
return string.format( | |||
cfg[opts.lang][key].format, | |||
imagefunc(id), -- 画像 | |||
imagefunc(id, | classes, -- 追加クラス | ||
name) -- 表示名 | |||
end | |||
function p.tactical(id, opts) | |||
return getSimpleResource('tactical', id, opts, iu.tactical, nu.tactical) | |||
end | end | ||
local function getConditionalLinkResource(key, id, opts, imagefunc, namefunc, | local function getConditionalLinkResource(key, id, opts, imagefunc, namefunc, idclassfunc) | ||
opts = opts or { lang = 'ja' } | opts = opts or { lang = 'ja' } | ||
opts.lang = opts.lang or 'ja' | opts.lang = opts.lang or 'ja' | ||
opts.size = opts.size or 16 | |||
local classes = buildClasses(opts) | local classes = buildClasses(opts) | ||
local name = namefunc(id, opts.lang) | local name = namefunc(id, opts.lang) | ||
local format, link = getLinkFormat(opts.link, name, cfg[opts.lang][key]) | |||
local format, link = getLinkFormat(opts.link, name, | return string.format( | ||
format, | |||
imagefunc(id, { -- 画像 | |||
imagefunc(id, { link = link, | lang = opts.lang, | ||
link = link, | |||
size = opts.size, | |||
}), | |||
idclassfunc(id), -- クラス用ID | |||
classes, -- 追加クラス | |||
name) -- 表示名 | |||
end | end | ||
function p.ammo(id, opts) | function p.ammo(id, opts) | ||
return | local idclassFunction = function(id) | ||
if aw.stringstarts(id, 'special_') then | |||
return 'special' | |||
else | |||
return id | |||
end | |||
end | |||
return getConditionalLinkResource('ammo', id, opts, iu.ammo, nu.ammo, idclassFunction) | |||
end | end | ||
function p.hopup(id, opts) | function p.hopup(id, opts) | ||
local | local rarity = opts and opts.rarity or mw.loadData('Module:Stat/Hopup')[id].rarity | ||
local imageFunction = function(id, opts) | |||
opts.rarity = rarity | |||
return iu.hopup(id, opts) | |||
end | |||
local idclassFunction = function() | |||
return rarity | |||
end | end | ||
return getConditionalLinkResource('hopup', id, opts, iu.hopup, nu.hopup, | return getConditionalLinkResource('hopup', id, opts, iu.hopup, nu.hopup, idclassFunction) | ||
end | end | ||
136行目: | 115行目: | ||
return string.format( | return string.format( | ||
cfg[opts.lang].level.none_format, | cfg[opts.lang].level.none_format, | ||
imagefunc( | imagefunc(level), | ||
namefunc(opts.lang)) | namefunc(opts.lang)) | ||
end | end | ||
142行目: | 121行目: | ||
return string.format( | return string.format( | ||
cfg[opts.lang].level.format[1 + level], | cfg[opts.lang].level.format[1 + level], | ||
imagefunc( | imagefunc(level), | ||
classes, | classes, | ||
namefunc(opts.lang)) | namefunc(opts.lang)) | ||
148行目: | 127行目: | ||
function p.gear(id, level, opts) | function p.gear(id, level, opts) | ||
local imgfn = function(level) | |||
return iu.gear(id, level) | |||
end | |||
local namefn = function(lang) | |||
return nu.gear(id, lang) | return nu.gear(id, lang) | ||
end) | end | ||
return getLevelResource(level, opts, imgfn, namefn) | |||
end | end | ||
function p.extmag(id, level, opts) | function p.extmag(id, level, opts) | ||
local imgfn = function(level) | |||
return iu.attachment(nu.extmag(id, 'ja'), level) | |||
end | |||
local namefn = function(lang) | |||
return nu.extmag(id, lang) | return nu.extmag(id, lang) | ||
end) | end | ||
return getLevelResource(level, opts, imgfn, namefn) | |||
end | end | ||
function __bolt_imagefunc(level) | |||
return iu.attachment(nu.bolt('ja'), level) | |||
end | |||
function p.bolt(level, opts) | function p.bolt(level, opts) | ||
return getLevelResource(level, opts, | return getLevelResource(level, opts, __bolt_imagefunc, nu.bolt) | ||
end | end | ||
return p | return p |
2021年8月31日 (火) 09:45時点における最新版
このモジュールについての説明文ページを モジュール:Utility/ImageWithName/doc に作成できます
local p = {} local cfg = mw.loadData('Module:Utility/ImageWithName/configuration') local aw = require('Module:Utility/Library') local function buildClasses(opts) local classes if type(opts.classes) == 'string' then if opts.desktopOnly then classes = ' ' .. opts.classes .. ' text-desktoponly' else classes = ' ' .. opts.classes end else if opts.desktopOnly then classes = ' text-desktoponly' else classes = '' end end return classes end local function getLinkFormat(link, name, cfg) local linkString if link then if link ~= '' then linkString = name else return string.format('%%s %s', cfg.format), link end else linkString = string.format(cfg.defaultLink, name) end return string.format('%%s [[%s|%s]]', linkString, cfg.format), linkString end local iu = require('Module:Utility/Image') local nu = require('Module:Utility/Name') local function getSimpleResource(key, id, opts, imagefunc, namefunc) opts = opts or { lang = 'ja' } opts.lang = opts.lang or 'ja' local classes = buildClasses(opts) local name = namefunc(id, opts.lang) return string.format( cfg[opts.lang][key].format, imagefunc(id), -- 画像 classes, -- 追加クラス name) -- 表示名 end function p.tactical(id, opts) return getSimpleResource('tactical', id, opts, iu.tactical, nu.tactical) end local function getConditionalLinkResource(key, id, opts, imagefunc, namefunc, idclassfunc) opts = opts or { lang = 'ja' } opts.lang = opts.lang or 'ja' opts.size = opts.size or 16 local classes = buildClasses(opts) local name = namefunc(id, opts.lang) local format, link = getLinkFormat(opts.link, name, cfg[opts.lang][key]) return string.format( format, imagefunc(id, { -- 画像 lang = opts.lang, link = link, size = opts.size, }), idclassfunc(id), -- クラス用ID classes, -- 追加クラス name) -- 表示名 end function p.ammo(id, opts) local idclassFunction = function(id) if aw.stringstarts(id, 'special_') then return 'special' else return id end end return getConditionalLinkResource('ammo', id, opts, iu.ammo, nu.ammo, idclassFunction) end function p.hopup(id, opts) local rarity = opts and opts.rarity or mw.loadData('Module:Stat/Hopup')[id].rarity local imageFunction = function(id, opts) opts.rarity = rarity return iu.hopup(id, opts) end local idclassFunction = function() return rarity end return getConditionalLinkResource('hopup', id, opts, iu.hopup, nu.hopup, idclassFunction) end local function getLevelResource(level, opts, imagefunc, namefunc) level = level or 0 opts = opts or { lang = 'ja' } opts.lang = opts.lang or 'ja' if level == 0 and opts.useShortLabel then return cfg[lang].level.none end if level > 5 then level = 5 end local classes = buildClasses(opts) if level == 0 and classes == '' then return string.format( cfg[opts.lang].level.none_format, imagefunc(level), namefunc(opts.lang)) end return string.format( cfg[opts.lang].level.format[1 + level], imagefunc(level), classes, namefunc(opts.lang)) end function p.gear(id, level, opts) local imgfn = function(level) return iu.gear(id, level) end local namefn = function(lang) return nu.gear(id, lang) end return getLevelResource(level, opts, imgfn, namefn) end function p.extmag(id, level, opts) local imgfn = function(level) return iu.attachment(nu.extmag(id, 'ja'), level) end local namefn = function(lang) return nu.extmag(id, lang) end return getLevelResource(level, opts, imgfn, namefn) end function __bolt_imagefunc(level) return iu.attachment(nu.bolt('ja'), level) end function p.bolt(level, opts) return getLevelResource(level, opts, __bolt_imagefunc, nu.bolt) end return p