BloodCaster (обс. | вклад) (Приведение размеров интерфейса печки в соответствие с размерами других сеток крафта) |
BloodCaster (обс. | вклад) Нет описания правки |
||
(не показано 10 промежуточных версий 2 участников) | |||
Строка 26: | Строка 26: | ||
end |
end |
||
− | local body = mw.html.create(' |
+ | local body = mw.html.create('div'):addClass('craft-gui gui') |
local input = body:tag('span'):addClass('mcui-input') |
local input = body:tag('span'):addClass('mcui-input') |
||
Строка 74: | Строка 74: | ||
end |
end |
||
− | return tostring( mw.html.create( 'div' ):node( body ) ) |
||
− | end |
||
− | |||
− | -- Печка (обжиг) |
||
− | function p.furnace( f ) |
||
− | local args = f |
||
− | if f == mw.getCurrentFrame() then |
||
− | args = f:getParent().args |
||
− | else |
||
− | f = mw.getCurrentFrame() |
||
− | end |
||
− | |||
− | local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Furnace' ):cssText( 'text-align:center;height:108px;width:200px' ) |
||
− | |||
− | local input = body:tag( 'span' ):addClass( 'mcui-input' ) |
||
− | input:wikitext( addSlot( args, 'Ресурс', 'Р' ) ) |
||
− | local fuel = input:tag( 'span' ):addClass( 'mcui-fuel' ):tag( 'br' ):done() |
||
− | local fuelImg = args["Расход"] or '' |
||
− | local burning = args["Ресурс"] or '' ~= '' and args["Топливо"] or '' ~= '' |
||
− | if not burning then |
||
− | fuel:addClass( 'mcui-inactive' ) |
||
− | if fuelImg ~= '' then |
||
− | fuelImg = fuelImg .. ' (in-active)' |
||
− | end |
||
− | end |
||
− | if fuelImg ~= '' and args["Мод"] then |
||
− | fuel:cssText( 'background-image:{{FileUrl|Grid layout ' .. fuelImg .. ' (' .. args["Мод"] .. ').png}}' |
||
− | ) |
||
− | end |
||
− | input:wikitext( addSlot( args, 'Топливо', 'Т' ) ) |
||
− | |||
− | local arrow = body:tag( 'span' ):addClass( 'mcui-arrow' ):tag( 'br' ):done() |
||
− | local arrowImg = args["Прогресс"] or '' |
||
− | if not burning or ( args["Выход"] or '' ) == '' then |
||
− | arrow:addClass( 'mcui-inactive' ) |
||
− | if arrowImg ~= '' then |
||
− | arrowImg = arrowImg .. ' (in-active)' |
||
− | end |
||
− | end |
||
− | if arrowImg ~= '' and args["Мод"] then |
||
− | arrow:cssText( 'height: 100%; vertical-align: middle; background:none; margin:0;width:0' ) |
||
− | body:tag( 'span' ):cssText( 'vertical-align: middle;' ):wikitext( '[[File:Grid layout ' .. arrowImg .. ' Progress (' .. args["Мод"] .. ').png|Это рецепт для устройства ' .. arrowImg .. ' из модификации ' .. args["Мод"] .. '.|link=' .. args["Мод"] .. '/' .. arrowImg .. ']]' ) |
||
− | input:cssText( 'margin-right:14px' ) |
||
− | end |
||
− | |||
− | local output = body:tag( 'span' ) |
||
− | :addClass( 'mcui-output' ) |
||
− | :wikitext( addSlot( args, 'Выход', 'В', 'invslot-large' ) ) |
||
− | |||
− | if arrowImg ~= '' and args["Мод"] then |
||
− | output:cssText( 'margin-left:18px' ) |
||
− | end |
||
− | |||
return tostring( mw.html.create( 'div' ):node( body ) ) |
return tostring( mw.html.create( 'div' ):node( body ) ) |
||
end |
end |
Версия от 10:53, 24 июля 2020
Этот модуль реализует общие шаблоны интерфейса, чтобы избежать чрезмерной нагрузки от #invoke вызовов.
Зависимости
Смотрите также
- {{Верстак}}
- {{Печь}}
- {{Варочная стойка}}
- {{Камнерез}}
----------------------------------------------------------------------------------------------------
-- Модуль для отображения окон интерфейса (крафта, обжига, варки...) на страницах Minecraft Wiki.
----------------------------------------------------------------------------------------------------
-- Внутренние функции
local slot = require('Модуль:Инвентарный слот').slot
local addSlot = function( args, item, prefix, class, default )
prefix = prefix or item
return slot{
args[item], ["мод"] = args["Мод"], ["ссылка"] = args[prefix .. 'Ссылка'],
["назв"] = args[prefix .. 'Назв'], ["класс"] = class, ["умолчание"] = default
}
end
-- Экспортируемые функции
local p = {}
-- Верстак (крафт)
function p.craftingTable( f )
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('div'):addClass('craft-gui gui')
local input = body:tag('span'):addClass('mcui-input')
for num = 1, 3 do
local row = input:tag('span'):addClass('mcui-row')
for _, letter in ipairs{'A', 'B', 'C'} do
row:wikitext(addSlot(args, letter .. num))
end
end
local arrow = body:tag('span'):addClass('mcui-arrow'):tag('br'):done()
if args["Стрелка"] or '' ~= '' then
arrow:cssText( 'background-image:{{FileUrl|Grid layout ' .. args["Стрелка"] .. ' (' .. args["Мод"] .. ').png}}'
)
end
body
:tag( 'span' )
:addClass( 'mcui-output' )
:wikitext( addSlot( args, 'Выход', 'В', 'invslot-large' ) )
local shapeless = args["бесформенный"] or ''
local fixed = args["фиксированный"] or ''
if shapeless ~= '' or fixed ~= '' then
local icon = body:tag( 'span' )
:addClass( 'mcui-icons' )
:tag( 'span' )
:tag( 'br' )
:done()
if shapeless ~= '' then
icon:addClass( 'mcui-shapeless' )
:attr( 'title',
'Этот рецепт бесформенный, ресурсы могут располагаться в сетке верстака в любом порядке.'
)
elseif fixed ~= '' then
local notFixed = args["нефиксировано"] or '' -- указывайте в родительном падеже
local exceptFixed = ''
if notFixed ~= '' then
exceptFixed = ', за исключением ' .. notFixed
end
icon:addClass( 'mcui-fixed' )
:attr( 'title',
'Этот рецепт фиксированный, его ингредиенты не могут быть перемещены или зеркально отражены' .. exceptFixed .. '.'
)
end
end
return tostring( mw.html.create( 'div' ):node( body ) )
end
-- Варочная стойка (варка)
function p.brewingStand( f )
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Brewing_Stand' )
local input = body:tag( 'span' ):addClass( 'mcui-input' )
local inactive = ( args["Ресурс"] or '' ) == '' or
( ( args["Выход1"] or '' ) == '' and ( args["Выход2"] or '' ) == '' and ( args["Выход3"] or '' ) == '' )
if not inactive then
local fuelslot = 'Огненный порошок'
input:wikitext( slot{ fuelslot } )
else
input:wikitext( slot{ ["умолчание"] = 'Grid_layout_Brewing_Blaze_Empty' } )
end
input:tag( 'span' ):addClass( 'mcui-blaze' ):tag( 'br' )
input:tag( 'span' ):addClass( 'mcui-bubbling' ):tag( 'br' )
input:wikitext( addSlot( args, 'Ресурс', 'Р' ) )
input:tag( 'span' ):addClass( 'mcui-arrow' ):tag( 'br' )
if inactive
then
input:addClass( 'mcui-inactive' )
end
body:tag( 'span' ):addClass( 'mcui-paths' ):tag( 'br' )
local output = body:tag( 'span' ):addClass( 'mcui-output' )
for i = 1, 3 do
output:wikitext( addSlot( args, 'Выход' .. i, 'В' .. i, 'mcui-output' .. i ) )
end
return tostring( mw.html.create( 'div' ):node( body ) )
end
return p