Warning.png

Поддержка Wiki прекращена, она доступна в режиме архива. Информация в ней устарела и может быть неактуальной.

Модуль:Интерфейс — различия между версиями

Материал из Hilarious Wiki
Перейти к: навигация, поиск
 
(не показано 7 промежуточных версий этого же участника)
Строка 1: Строка 1:
 
----------------------------------------------------------------------------------------------------
 
----------------------------------------------------------------------------------------------------
-- Модуль для отображения окон интерфейса (крафта, обжига, варки...).
+
-- Модуль для отображения окон интерфейса (крафта, обжига, варки...) на страницах Minecraft Wiki.
 
----------------------------------------------------------------------------------------------------
 
----------------------------------------------------------------------------------------------------
  
Строка 38: Строка 38:
 
local arrow = body:tag('span'):addClass('mcui-arrow'):tag('br'):done()
 
local arrow = body:tag('span'):addClass('mcui-arrow'):tag('br'):done()
 
if args["Стрелка"] or '' ~= '' then
 
if args["Стрелка"] or '' ~= '' then
arrow:cssText( 'background-image:{{FileUrl|' .. args["Стрелка"] .. ' (' .. args["Мод"] .. ').png}}'
+
arrow:cssText( 'background-image:{{FileUrl|Grid layout ' .. args["Стрелка"] .. ' (' .. args["Мод"] .. ').png}}'
 
)
 
)
 
end
 
end
Строка 100: Строка 100:
 
end
 
end
 
if fuelImg ~= '' and args["Мод"] then
 
if fuelImg ~= '' and args["Мод"] then
fuel:cssText( 'background-image:{{FileUrl|' .. fuelImg .. ' (' .. args["Мод"] .. ').png}}'
+
fuel:cssText( 'background-image:{{FileUrl|Grid layout ' .. fuelImg .. ' (' .. args["Мод"] .. ').png}}'
 
)
 
)
 
end
 
end
Строка 114: Строка 114:
 
end
 
end
 
if arrowImg ~= '' and args["Мод"] then
 
if arrowImg ~= '' and args["Мод"] then
         arrow:cssText( 'height: 100%; vertical-align: middle;background:none;margin:0;width:0' )
+
         arrow:cssText( 'height: 100%; vertical-align: middle; background:none; margin:0;width:0' )
         body:wikitext( '[[File:' .. arrowImg .. ' Progress (' .. args["Мод"] .. ').png|link=|middle]]' )
+
         body:wikitext( '[[File:Grid layout ' .. arrowImg .. ' Progress (' .. args["Мод"] .. ').png|link=|middle]]' )
 
         input:cssText( 'margin-right:14px' )
 
         input:cssText( 'margin-right:14px' )
 
     end
 
     end
Строка 141: Строка 141:
 
local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Brewing_Stand' )
 
local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Brewing_Stand' )
 
local input = body:tag( 'span' ):addClass( 'mcui-input' )
 
local input = body:tag( 'span' ):addClass( 'mcui-input' )
local active = ( args["Ресурс"] or '' ) == '' or
+
local inactive = ( args["Ресурс"] or '' ) == '' or
 
( ( args["Выход1"] or '' ) == '' and ( args["Выход2"] or '' ) == '' and ( args["Выход3"] or '' ) == '' )
 
( ( args["Выход1"] or '' ) == '' and ( args["Выход2"] or '' ) == '' and ( args["Выход3"] or '' ) == '' )
  
     if ( args["Топливо"] or '' ) == '' then
+
     if not inactive then
         input:wikitext( slot{ 'Огненный порошок' } )
+
        local fuelslot = 'Огненный порошок'
 +
         input:wikitext( slot{ fuelslot } )
 
     else
 
     else
    input:wikitext( addSlot( args, 'Топливо', 'Т', 'Grid_layout_Brewing_Blaze_Empty' ) )
+
        input:wikitext( slot{ ["умолчание"] = 'Grid_layout_Brewing_Blaze_Empty' } )
 
     end
 
     end
  
Строка 154: Строка 155:
 
input:wikitext( addSlot( args, 'Ресурс', 'Р' ) )
 
input:wikitext( addSlot( args, 'Ресурс', 'Р' ) )
 
input:tag( 'span' ):addClass( 'mcui-arrow' ):tag( 'br' )
 
input:tag( 'span' ):addClass( 'mcui-arrow' ):tag( 'br' )
if not active
+
if inactive
 
then
 
then
 
input:addClass( 'mcui-inactive' )
 
input:addClass( 'mcui-inactive' )

Текущая версия на 12:18, 21 августа 2016

Для документации этого модуля может быть создана страница Модуль:Интерфейс/док

----------------------------------------------------------------------------------------------------
-- Модуль для отображения окон интерфейса (крафта, обжига, варки...) на страницах 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('span'):addClass('mcui mcui-Crafting_Table')
	
	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.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( 'height:108px' )
	
	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:wikitext( '[[File:Grid layout ' .. arrowImg .. ' Progress (' .. args["Мод"] .. ').png|link=|middle]]' )
        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 ) )
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