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

мНет описания правки
Откат
Метка: ручная отмена
Строка 1: Строка 1:
local p = {}
local p = {}


-- Функция для получения имени предмета
function p.getname(frame, entid)
    local id = frame.args[1] or entid
    if not id then
        return "Не найдено"
    end
    return mw.getCurrentFrame():callParserFunction("#invoke", {"Entity Lookup", "getname", id})
end
-- Функция для получения описания предмета
function p.getdesc(frame, entid)
    local id = frame.args[1] or entid
    if not id then
        return "Не найдено"
    end
    return mw.getCurrentFrame():callParserFunction("#invoke", {"Entity Lookup", "getdesc", id})
end
-- Функция для создания текстовой подсказки
function p.createtexttooltip(frame)
    local id = frame.args[2]
    local entity = p.getname(frame, id)
    local desc = p.getdesc(frame, id)
    local stats = mw.getCurrentFrame():callParserFunction("Особое", id)
    local img = frame.args["img"] or "Mousegif.gif"
    if entity and entity ~= "Не найдено" then
        local tooltipText = "{{Tooltip|" .. frame.args[1] .. "|" .. entity .. "|" .. string.gsub(desc, "\n", "<br>") .. "|" .. stats .. "|img=" .. img .. "}}"
        return mw.getCurrentFrame():preprocess(tooltipText)
    else
        return mw.getCurrentFrame():preprocess("{{Tooltip|" .. frame.args[1] .. "|Не найден|Предмет не найден|img=Mousegif.gif}}")
    end
end
-- Функция для создания изображённой подсказки
function p.createimagetooltip(frame)
    local id = frame.args[2]
    local entity = p.getname(frame, id)
    local desc = p.getdesc(frame, id)
    local stats = mw.getCurrentFrame():callParserFunction("Особое", id)
    local img = frame.args[1] or "Mousegif.gif"
    if entity and entity ~= "Не найдено" then
        local tooltipText = "{{Tooltip|[[Файл:" .. img .. "|64x64px|link=]]|" .. entity .. "|" .. desc .. "|" .. stats .. "|img=" .. img .. "}}"
        return mw.getCurrentFrame():preprocess(tooltipText)
    else
        return mw.getCurrentFrame():preprocess("{{Tooltip|[[Файл:Mousegif.gif|64x64px|left|middle|link=]]|" .. entity .. "|" .. desc .. "|" .. stats .. "}}")
    end
end
-- Функция для генерации ячеек таблицы
function p.templateCells(frame)
function p.templateCells(frame)
     local color = frame.args.color or ""  -- Цвет фона
     local color = frame.args.color or ""  -- Цвет фона