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

мНет описания правки
мНет описания правки
 
(не показано 13 промежуточных версий этого же участника)
Строка 6: Строка 6:
local itemId = frame.args.itemId or ""  -- ID предмета
local itemId = frame.args.itemId or ""  -- ID предмета


local damage = frame.args.damage or ""
local damage = frame.args.damage or "" -- Ввод в ячейк урона
local stamina = tonumber(frame.args.stamina) or 0
local stamina = tonumber(frame.args.stamina) or 0 -- Выносливость
local blunt = tonumber(frame.args.blunt) or 0
local blunt = tonumber(frame.args.blunt) or 0 -- Ушибы
local piercing = tonumber(frame.args.piercing) or 0
local slash = tonumber(frame.args.slash) or 0 -- Режущие
local heat = tonumber(frame.args.heat) or 0
local piercing = tonumber(frame.args.piercing) or 0 -- Уколы
local radiation = tonumber(frame.args.radiation) or 0
local heat = tonumber(frame.args.heat) or 0 -- Термические
local structural = tonumber(frame.args.structural) or 0
local radiation = tonumber(frame.args.radiation) or 0 -- Кислотные
local caustic = tonumber(frame.args.caustic) or 0 -- Радиация
local structural = tonumber(frame.args.structural) or 0 -- Структурные


local fireRate = tonumber(frame.args.fireRate) or 0
local fireRate = tonumber(frame.args.fireRate) or 1 -- Скорострельность
local ammunition = frame.args.ammunition or "-"
fireRate = string.format("%.1f", fireRate)  -- Всегда форматируем с одним знаком после запятой
local caliber = frame.args.caliber or "-"
local ammunition = frame.args.ammunition or "-" -- Обойма
local caliber = frame.args.caliber or "-" -- Калибр


local description = frame.args.description or "Описание отсутствует"
local description = frame.args.description or "Описание отсутствует" -- Описание
local location = frame.args.location or ""
local location = frame.args.location or "" -- Местонахождения
local created = frame.args.created or "" -- Создаётя


-- Расчет DPS и data-sort-value (без учета structural и stamina)
-- Если dps и dataSort заданы вручную, используем их, иначе рассчитываем по формуле
local dps = fireRate * (blunt + piercing + heat + radiation)
local dps = frame.args.dps or fireRate * (blunt + slash + piercing + heat + radiation + caustic) -- Значения DPS
local dataSort = blunt + piercing + heat + radiation
local dataSort = tonumber(frame.args.dataSort) or (blunt + slash + piercing + heat + radiation + caustic) -- Значения data-sort-value


-- Формирование строки таблицы
-- Формирование строки таблицы
Строка 29: Строка 33:


-- Название
-- Название
out = out .. '!' .. frame:preprocess('{{Anchor|' .. anchorName .. '}}{{#invoke:Entity Lookup|createimagetooltip|File:' .. itemId .. '|' .. itemId .. '|Мета=64x64px}}')  
out = out .. '!' .. frame:preprocess('{{Anchor|' .. anchorName .. '}}{{#invoke:Entity Lookup|createimagetooltip|File:' .. itemId ..'.png|' .. itemId .. '|Мета=64x64px}}')  
out = out .. '<br>' .. frame:preprocess('{{#invoke:Entity Lookup|getname|' .. itemId .. '}}') .. '\n'
out = out .. '<br>' .. frame:preprocess('{{#invoke:Entity Lookup|getname|' .. itemId .. '}}') .. '\n'
-- Урон (выводим только непустые значения)
-- Урон (выводятся только непустые значения)
out = out .. '|data-sort-value=' .. dataSort .. '|\n'
out = out .. '|data-sort-value=' .. dataSort .. '|\n'
if damage ~= "" then
if damage ~= "" then
out = out '' .. damage .. '\n'
out = out .. damage .. '\n'
end
end
if stamina > 0 then
if stamina > 0 then
Строка 43: Строка 47:
if blunt > 0 then
if blunt > 0 then
out = out .. ': <span style="color:crimson"><b>' .. blunt .. '</b></span> Ушибы\n'
out = out .. ': <span style="color:crimson"><b>' .. blunt .. '</b></span> Ушибы\n'
end
if slash > 0 then
out = out .. ': <span style="color:indianred"><b>' .. slash .. '</b></span> Режущие\n'
end
end
if piercing > 0 then
if piercing > 0 then
Строка 52: Строка 59:
if radiation > 0 then
if radiation > 0 then
out = out .. ': <span style="color:limegreen"><b>' .. radiation .. '</b></span> Радиация\n'
out = out .. ': <span style="color:limegreen"><b>' .. radiation .. '</b></span> Радиация\n'
end
if caustic > 0 then
out = out .. ': <span style="color:plum"><b>' .. caustic .. '</b></span> Кислотные\n'
end
end
if structural > 0 then
if structural > 0 then
Строка 59: Строка 69:
-- Параметры  
-- Параметры  
out = out .. '|style="color:DodgerBlue"|<b>' .. fireRate .. '</b>\n'
out = out .. '|style="color:DodgerBlue"|<b>' .. fireRate .. '</b>\n'
out = out .. '|style="color:Yellow"|<b>' .. dps .. '</b>\n' -- Расчетное значение DPS
out = out .. '|style="color:Yellow"|<b>' .. dps .. '</b>\n'
out = out .. '|style="color:Aquamarine"|<b>' .. ammunition .. '</b>\n'
out = out .. '|style="color:Aquamarine"|<b>' .. ammunition .. '</b>\n'
out = out .. '|style="color:#77c1d9"|<b>' .. caliber .. '</b>\n'
if caliber ~= "" then
out = out .. '|style="color:#77c1d9"|<b>' .. caliber .. '</b>\n'
end


-- Описание
-- Описание
Строка 67: Строка 79:


-- Местоположение
-- Местоположение
out = out .. '|\n'
if location ~= "" then
if location ~= "" then
out = out .. '|\n' .. frame:preprocess('{{SlideMenu|overlay|color=#e1f6ff|title=Список [[File:Examine.svg.192dpi.png|24x24px]]|content=<p></p>' .. location .. '}}\n')
out = out .. frame:preprocess('{{SlideMenu|overlay|color=#e1f6ff|title=Список [[File:Examine.svg.192dpi.png|24x24px]]|content=<p></p>\n' .. location .. '}}\n')
else
end
out = out .. '|\n' .. frame:preprocess('{{FrameText|color=#82d1c4|content=Нет гарантированных мест спавна}}\n')
 
-- Создаётся
if created ~= "" then
out = out .. frame:preprocess('{{SlideMenu|overlay|color=#e1f6ff|border-color=#4c4c61|title=Создаётся [[File:hammer.svg.192dpi.png|24x24px]]|content=Создаётся в панели строительства<hr>\n' .. created .. '}}\n')
elseif location == "" then
out = out .. frame:preprocess('{{FrameText|color=#82d1c4|content=Нет гарантированных мест спавна}}\n')
end
end