新 Minecarft Wiki 1周年!
|
モジュール:Iconbar
ナビゲーションに移動
検索に移動
このモジュールは {{iconbar}}
を実装しています。また直接テンプレート:iconbar を使用するのではなくテンプレートから呼び出す形で使用するのが望ましいです。
親引数は自動的に直接渡された引数で上書きされます。
依存関係[ソースを編集]
関連項目[ソースを編集]
{{Armorbar}}
{{Healthbar}}
{{Hungerbar}}
{{Iconbar}}
- モジュール:Iconbar
[閲覧] [編集] [履歴] [更新]上記の解説は、モジュール:Iconbar/docから参照されています。
local p = {}
function p.bar( f )
local args = require( 'モジュール:ProcessArgs' ).merge()
local alt = args.alt or ''
local link = args.link or ''
local full = args.full
local half = args.half or 'Half ' .. full
local empty = args.empty or 'Empty ' .. full
local value = math.abs( tonumber( args.value ) or 0 ) / 2
local min = math.ceil( math.abs( tonumber( args.min ) or 0 ) / 2 )
local size = args.size or ''
local title = args.title or ''
local reverse = args.reverse or ''
local offset = args.offset or ''
if title:lower() == 'none' then
title = ''
elseif title ~= '' then
title = ' title="' .. title .. '"'
else
title = ' title="' .. value .. '"'
end
local fullIcon = ''
local halfIcon = ''
local emptyIcon = ''
if tonumber( size ) then
size = '|' .. size .. 'px'
elseif size ~= '' then
size = '|' .. size
end
if offset ~= '' then
offset = ' style="--icon-offset:' .. offset .. ';"'
else
offset = ' style="--icon-offset:-' .. ( ( size:match('%d+', 1) or 9 ) / 9 ) .. 'px;"'
end
if value == 0 then
emptyIcon = '[[ファイル:' .. empty .. size .. '|link=' .. link .. '|alt=' .. alt .. ']]'
else
fullIcon = string.rep( '[[ファイル:' .. full .. size .. '|link=' .. link .. '|alt=' .. alt .. ']]', math.floor( value ) )
if math.floor( value ) ~= value then
halfIcon = '[[ファイル:' .. half .. size .. '|link=' .. link .. '|alt=' .. alt .. ']]'
end
end
if min - value >= 1 then
emptyIcon = string.rep( '[[ファイル:' .. empty .. size .. '|link=' .. link .. '|alt=' .. alt .. ']]', min - math.ceil( value ) )
end
if reverse ~= '' then
return '<span class="iconbar pixel-image nowrap"' .. offset .. title .. '>' .. emptyIcon .. halfIcon .. fullIcon .. '</span>'
else
return '<span class="iconbar pixel-image nowrap"' .. offset .. title .. '>' .. fullIcon .. halfIcon .. emptyIcon .. '</span>'
end
end
return p