Модуль:FirearmsStats
Материал из Space Station 14 Вики
{{#invoke:FirearmsStats|templateCells | anchorName = НазванияПредмета | itemId = АйдиПредмета | stamina = Выносливость | blunt = Ушибы | slash = Режущие | piercing = Уколы | heat = Термические | сaustic = Кислотные | radiation = Радиация | structural = Структурные <!-- Ручной ввод в ячейки, если у оружия особый тип урона --> | damage = Урон | dataSort = Значения data-sort-value | dps = Значения DPS | fireRate = Скорострельность | ammunition = Обойма | caliber = Калибр | description = Описание | location = Местонахождение | created = Создаётся (Используйте, если предмет крафтится) }}
local p = {}
-- Функция для создания таблицы с заданными параметрами
function p.templateCells(frame)
local anchorName = frame.args.anchorName or "" -- Название якоря
local itemId = frame.args.itemId or "" -- ID предмета
local stamina = tonumber(frame.args.stamina) or 0
local blunt = tonumber(frame.args.blunt) or 0
local piercing = tonumber(frame.args.piercing) or 0
local heat = tonumber(frame.args.heat) or 0
local radiation = tonumber(frame.args.radiation) or 0
local structural = tonumber(frame.args.structural) or 0
local fireRate = tonumber(frame.args.fireRate) or 0
local ammunition = frame.args.ammunition or "-"
local caliber = frame.args.caliber or "-"
local description = frame.args.description or "Описание отсутствует"
local location = frame.args.location or "Неизвестно"
-- Расчет DPS и data-sort-value (без учета structural и stamina)
local dps = fireRate * (blunt + piercing + heat + radiation)
local dataSort = blunt + piercing + heat + radiation
-- Формирование строки таблицы
local out = ""
-- Название
out = out .. '!' .. frame:preprocess('{{Anchor|' .. anchorName .. '}}{{#invoke:Entity Lookup|createimagetooltip|File:' .. itemId .. '|' .. itemId .. '|Мета=64x64px}}')
out = out .. '<br>' .. frame:preprocess('{{#invoke:Entity Lookup|getname|' .. itemId .. '}}') .. '\n'
-- Урон
out = out .. '|data-sort-value=' .. dataSort .. '|\n' ..
'' .. damage .. '\n' ..
': <span style="color:DodgerBlue"><b>' .. stamina .. '</b></span> Выносливость\n' ..
': <span style="color:crimson"><b>' .. blunt .. '</b></span> Ушибы\n' ..
': <span style="color:darksalmon"><b>' .. piercing .. '</b></span> Уколы\n' ..
': <span style="color:orange"><b>' .. heat .. '</b></span> Термические\n' ..
': <span style="color:limegreen"><b>' .. radiation .. '</b></span> Радиация\n' ..
': <span style="color:DarkGray"><b>' .. structural .. '</b></span> Структурные\n'
-- Параметры
out = out .. '|style="color:DodgerBlue"|<b>' .. fireRate .. '</b>\n'
out = out .. '|style="color:Yellow"|<b>' .. dps .. '</b>\n' -- Расчетное значение DPS
out = out .. '|style="color:Aquamarine"|<b>' .. ammunition .. '</b>\n'
out = out .. '|style="color:#77c1d9"|<b>' .. caliber .. '</b>\n'
-- Описание и местоположение
out = out .. '|\n' .. description .. '\n'
out = out .. '|\n' .. frame:preprocess('{{SlideMenu|overlay|color=#e1f6ff|title=Список [[File:Examine.svg.192dpi.png|24x24px]]|content=<p></p>' .. location .. '}}\n')
out = out .. '|-\n'
return out
end
return p