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

Материал из Space Station 14 Вики
мНет описания правки
мНет описания правки
 
(не показана 31 промежуточная версия этого же участника)
Строка 2: Строка 2:


function p.templateCells(frame)
function p.templateCells(frame)
     -- Получаем аргументы шаблона с использованием frame:preprocess
     local anchorName = frame.args.anchorName or ""  -- Название якоря
     local args = frame:preprocess(frame.args)
     local itemId = frame.args.itemId or ""  -- ID предмета
 
     local image = frame.args.image or ""  -- Путь к изображению предмета
     local color = args.color or ""  -- Цвет фона
     local color = frame.args.color or ""  -- Цвет фона первой ячейки
     local anchorName = args.anchorName or ""  -- Название якоря
     local backgroundColor = frame.args.backgroundColor or "" -- Цвет фона для всех ячеек, кроме первой
     local image = args.image or "" -- Путь к изображению предмета
     local class = frame.args.class or "" -- Класс
     local itemId = args.itemId or "" -- ID предмета
      
      
     local protection1 = args.protection1 or "-" -- Ударный
     local protBlunt = frame.args.protBlunt or "-" -- Ударный
     local protection2 = args.protection2 or "-" -- Режущий
     local protSlash = frame.args.protSlash or "-" -- Режущий
     local protection3 = args.protection3 or "-" -- Колющий
     local protPiercing = frame.args.protPiercing or "-" -- Колющий
     local protection4 = args.protection4 or "-" -- Высокотемпературный
     local protHeat = frame.args.protHeat or "-" -- Высокотемпературный
     local protection5 = args.protection5 or "-" -- Кислотный
     local protRadiation = frame.args.protRadiation or "-" -- Кислотный
     local protection6 = args.protection6 or "-" -- Радиационный
     local protCaustic = frame.args.protCaustic or "-" -- Радиационный
     local protection7 = args.protection7 or "-" -- Взрывной
     local protExplosion = frame.args.protExplosion or "-" -- Взрывной
      
      
     local description = args.description or "" -- Описание
     local description = frame.args.description or "" -- Описание
     local location = args.location or "" -- Местонахождения
     local location = frame.args.location or "" -- Местонахождение


    -- Формирование строк для ячеек таблицы
     local out = ""
     local out = ""
 
     out = out .. '!class="' .. class .. '" style="background-color: ' .. color .. ';"|' .. frame:preprocess('{{Anchor|' .. anchorName .. '}}')
    -- Формирование строк для ячеек таблицы
    out = out .. frame:preprocess('{{#invoke:Entity Lookup|createimagetooltip|File:' .. image .. '|' .. itemId .. '|Мета=64x64px}}')
     out = out .. '!style="background-color: ' .. color .. ';"|{{Anchor|' .. anchorName .. '}}{{#invoke:Entity Lookup|createimagetooltip|File:' .. image .. '|' .. itemId .. '|Мета=64x64px}}<br>{{#invoke:Entity Lookup|getname|' .. itemId .. '}} \n'
    out = out .. '<br>' .. frame:preprocess('{{#invoke:Entity Lookup|getname|' .. itemId .. '}}') .. '\n'
     out = out .. '|style="font-weight:500;color: crimson"|' .. protection1 .. ' \n'
     out = out .. '|class="' .. class .. '" style="font-weight:bold;color: crimson;background-color: ' .. backgroundColor .. '"|' .. protBlunt .. '\n'
     out = out .. '|style="font-weight:500;color: indianred"|' .. protection2 .. ' \n'
     out = out .. '|class="' .. class .. '" style="font-weight:bold;color: indianred;background-color: ' .. backgroundColor .. '"|' .. protSlash .. '\n'
     out = out .. '|style="font-weight:500;color: darksalmon"|' .. protection3 .. ' \n'
     out = out .. '|class="' .. class .. '" style="font-weight:bold;color: darksalmon;background-color: ' .. backgroundColor .. '"|' .. protPiercing .. '\n'
     out = out .. '|style="font-weight:500;color: orange"|' .. protection4 .. ' \n'
     out = out .. '|class="' .. class .. '" style="font-weight:bold;color: orange;background-color: ' .. backgroundColor .. '"|' .. protHeat .. '\n'
     out = out .. '|style="font-weight:500;color: plum"|' .. protection5 .. ' \n'
     out = out .. '|class="' .. class .. '" style="font-weight:bold;color: plum;background-color: ' .. backgroundColor .. '"|' .. protCaustic .. '\n'
     out = out .. '|style="font-weight:500;color: limegreen"|' .. protection6 .. ' \n'
     out = out .. '|class="' .. class .. '" style="font-weight:bold;color: limegreen;background-color: ' .. backgroundColor .. '"|' .. protRadiation .. '\n'
     out = out .. '|style="font-weight:500;color: tan"|' .. protection7 .. ' \n'
     out = out .. '|class="' .. class .. '" style="font-weight:bold;color: tan;background-color: ' .. backgroundColor .. '"|' .. protExplosion .. '\n'
     out = out .. '|\n' .. description .. '\n\n|\n' .. location .. '\n|-\n'
     out = out .. '|class="' .. class .. '" style="background-color: ' .. backgroundColor .. '"|\n' .. description .. '\n'
    out = out .. '|class="' .. class .. '" style="background-color: ' .. backgroundColor .. '"|\n' .. location .. '\n|-'


     return out
     return out

Текущая версия от 18:30, 22 августа 2024

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

local p = {}

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

    -- Формирование строк для ячеек таблицы
    local out = ""
    out = out .. '!class="' .. class .. '" style="background-color: ' .. color .. ';"|' .. frame:preprocess('{{Anchor|' .. anchorName .. '}}') 
    out = out .. frame:preprocess('{{#invoke:Entity Lookup|createimagetooltip|File:' .. image .. '|' .. itemId .. '|Мета=64x64px}}')
    out = out .. '<br>' .. frame:preprocess('{{#invoke:Entity Lookup|getname|' .. itemId .. '}}') .. '\n'
    out = out .. '|class="' .. class .. '" style="font-weight:bold;color: crimson;background-color: ' .. backgroundColor .. '"|' .. protBlunt .. '\n'
    out = out .. '|class="' .. class .. '" style="font-weight:bold;color: indianred;background-color: ' .. backgroundColor .. '"|' .. protSlash .. '\n'
    out = out .. '|class="' .. class .. '" style="font-weight:bold;color: darksalmon;background-color: ' .. backgroundColor .. '"|' .. protPiercing .. '\n'
    out = out .. '|class="' .. class .. '" style="font-weight:bold;color: orange;background-color: ' .. backgroundColor .. '"|' .. protHeat .. '\n'
    out = out .. '|class="' .. class .. '" style="font-weight:bold;color: plum;background-color: ' .. backgroundColor .. '"|' .. protCaustic .. '\n'
    out = out .. '|class="' .. class .. '" style="font-weight:bold;color: limegreen;background-color: ' .. backgroundColor .. '"|' .. protRadiation .. '\n'
    out = out .. '|class="' .. class .. '" style="font-weight:bold;color: tan;background-color: ' .. backgroundColor .. '"|' .. protExplosion .. '\n'
    out = out .. '|class="' .. class .. '" style="background-color: ' .. backgroundColor .. '"|\n' .. description .. '\n'
    out = out .. '|class="' .. class .. '" style="background-color: ' .. backgroundColor .. '"|\n' .. location .. '\n|-'

    return out
end

return p