Модуль:ArmorStats: различия между версиями

Нет описания правки
Нет описания правки
Строка 12: Строка 12:


function p.templateCells(frame)
function p.templateCells(frame)
     local args = frame.args
     local color = frame.args.color or ""  -- Цвет фона первой ячейки
     local class = args.class or "custom-class"  -- Класс для обертывающего <div>
    local anchorName = frame.args.anchorName or ""  -- Название якоря
     local image = frame.args.image or ""  -- Путь к изображению предмета
    local itemId = frame.args.itemId or ""  -- ID предмета


    -- Получаем все аргументы для формирования содержимого таблицы
     local protBlunt = frame.args.protBlunt or "-" -- Ударный
     local color = args.color or ""
     local protSlash = frame.args.protSlash or "-" -- Режущий
    local anchorName = args.anchorName or ""
     local protPiercing = frame.args.protPiercing or "-" -- Колющий
    local image = args.image or ""
     local protHeat = frame.args.protHeat or "-" -- Высокотемпературный
    local itemId = args.itemId or ""
     local protRadiation = frame.args.protRadiation or "-" -- Радиационный
    local protBlunt = args.protBlunt or "-"
     local protCaustic = frame.args.protCaustic or "-" -- Кислотный
     local protSlash = args.protSlash or "-"
     local protExplosion = frame.args.protExplosion or "-" -- Взрывной
     local protPiercing = args.protPiercing or "-"
 
     local protHeat = args.protHeat or "-"
     local description = frame.args.description or "" -- Описание
     local protRadiation = args.protRadiation or "-"
     local location = frame.args.location or "" -- Местонахождение
     local protCaustic = args.protCaustic or "-"
     local backgroundColor = frame.args.backgroundColor or "" -- Цвет фона для всех ячеек, кроме первой
     local protExplosion = args.protExplosion or "-"
    local divClass = frame.args.divClass or "" -- Класс для div
     local description = args.description or ""
     local location = args.location or ""
     local backgroundColor = args.backgroundColor or ""


     -- Вызов функции из модуля Entity Lookup для создания image tooltip
     -- Вызов функции из модуля Entity Lookup для создания image tooltip
Строка 43: Строка 42:
     local borderColor = darkenColor(color)
     local borderColor = darkenColor(color)


     -- Формирование строк для ячеек таблицы
     -- Создание HTML
     local out = ""
     local div = mw.html.create('div')
    div:addClass(divClass)
 
    local tableContent = ""
     out = out .. '\n'
     out = out .. '\n'
     out = out .. '!style="background-color: ' .. color .. ';border-top: 1px solid ' .. borderColor .. ';border-bottom: 1px solid ' .. borderColor .. ';border-left: 2px solid ' .. borderColor .. ';"|' .. anchor  
     tableContent = tableContent .. '!style="background-color: ' .. color .. ';border-top: 1px solid ' .. borderColor .. ';border-bottom: 1px solid ' .. borderColor .. ';border-left: 2px solid ' .. borderColor .. ';"|' .. anchor  
     out = out .. imageTooltip
     tableContent = tableContent .. imageTooltip
     out = out .. '<br>' .. itemName .. '\n'
     tableContent = tableContent .. '<br>' .. itemName .. '\n'
     out = out .. '|style="font-weight:bold;color: crimson;background-color: ' .. backgroundColor .. '"|' .. protBlunt .. '\n'
     tableContent = tableContent .. '|style="font-weight:bold;color: crimson;background-color: ' .. backgroundColor .. '"|' .. protBlunt .. '\n'
     out = out .. '|style="font-weight:bold;color: indianred;background-color: ' .. backgroundColor .. '"|' .. protSlash .. '\n'
     tableContent = tableContent .. '|style="font-weight:bold;color: indianred;background-color: ' .. backgroundColor .. '"|' .. protSlash .. '\n'
     out = out .. '|style="font-weight:bold;color: darksalmon;background-color: ' .. backgroundColor .. '"|' .. protPiercing .. '\n'
     tableContent = tableContent .. '|style="font-weight:bold;color: darksalmon;background-color: ' .. backgroundColor .. '"|' .. protPiercing .. '\n'
     out = out .. '|style="font-weight:bold;color: orange;background-color: ' .. backgroundColor .. '"|' .. protHeat .. '\n'
     tableContent = tableContent .. '|style="font-weight:bold;color: orange;background-color: ' .. backgroundColor .. '"|' .. protHeat .. '\n'
     out = out .. '|style="font-weight:bold;color: plum;background-color: ' .. backgroundColor .. '"|' .. protRadiation .. '\n'
     tableContent = tableContent .. '|style="font-weight:bold;color: plum;background-color: ' .. backgroundColor .. '"|' .. protRadiation .. '\n'
     out = out .. '|style="font-weight:bold;color: limegreen;background-color: ' .. backgroundColor .. '"|' .. protCaustic .. '\n'
     tableContent = tableContent .. '|style="font-weight:bold;color: limegreen;background-color: ' .. backgroundColor .. '"|' .. protCaustic .. '\n'
     out = out .. '|style="font-weight:bold;color: tan;background-color: ' .. backgroundColor .. '"|' .. protExplosion .. '\n'
     tableContent = tableContent .. '|style="font-weight:bold;color: tan;background-color: ' .. backgroundColor .. '"|' .. protExplosion .. '\n'
     out = out .. '|style="background-color: ' .. backgroundColor .. '"|\n' .. description .. '\n'
     tableContent = tableContent .. '|style="background-color: ' .. backgroundColor .. '"|\n' .. description .. '\n'
     out = out .. '|style="background-color: ' .. backgroundColor .. '"|\n' .. location .. '\n|-'
     tableContent = tableContent .. '|style="background-color: ' .. backgroundColor .. '"|\n' .. location .. '\n|-'


     -- Обертываем результат в <div> с заданным классом
     div:wikitext(tableContent)
    local wrappedOut = '<div class="' .. class .. '">' .. out .. '</div>'


     return wrappedOut
     return tostring(div)
end
end


return p
return p