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

Материал из Space Station 14 Вики
(Новая страница: «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...»)
 
мНет описания правки
 
(не показано 6 промежуточных версий этого же участника)
Строка 3: Строка 3:
-- Функция для создания таблицы с заданными параметрами
-- Функция для создания таблицы с заданными параметрами
function p.templateCells(frame)
function p.templateCells(frame)
    local anchorName = frame.args.anchorName or ""  -- Название якоря
local anchorName = frame.args.anchorName or ""  -- Название якоря
    local itemId = frame.args.itemId or ""  -- ID предмета
local itemId = frame.args.itemId or ""  -- ID предмета


    local stamina = tonumber(frame.args.stamina) or 0
local damage = frame.args.damage or ""
    local blunt = tonumber(frame.args.blunt) or 0
local stamina = tonumber(frame.args.stamina) or 0
    local piercing = tonumber(frame.args.piercing) or 0
local blunt = tonumber(frame.args.blunt) or 0
    local heat = tonumber(frame.args.heat) or 0
local slash = tonumber(frame.args.slash) or 0
    local radiation = tonumber(frame.args.radiation) or 0
local piercing = tonumber(frame.args.piercing) or 0
    local structural = tonumber(frame.args.structural) or 0
local heat = tonumber(frame.args.heat) 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 0
    local ammunition = frame.args.ammunition or "-"
local ammunition = frame.args.ammunition or "-"
    local caliber = frame.args.caliber 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 ""


    -- Расчет DPS и data-sort-value (без учета structural и stamina)
-- Расчет DPS и data-sort-value (без учета structural и stamina)
    local dps = fireRate * (blunt + piercing + heat + radiation)
local dps = fireRate * (blunt + piercing + heat + radiation)
local dataSort = blunt + piercing + heat + radiation
local dataSort = blunt + slash + piercing + heat + radiation + caustic


    -- Формирование строки таблицы
-- Формирование строки таблицы
    local out = ""
local out = ""


    -- Название
-- Название
    out = out .. '!' .. frame:preprocess('{{Anchor|' .. anchorName .. '}}{{#invoke:Entity Lookup|createimagetooltip|File:' .. image .. '|' .. itemId .. '|Мета=64x64px}}')  
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 .. '<br>' .. frame:preprocess('{{#invoke:Entity Lookup|getname|' .. itemId .. '}}') .. '\n'
   
    -- Урон
-- Урон (выводятся только непустые значения)
    out = out .. '|data-sort-value=' .. dataSort .. '|\n' ..
out = out .. '|data-sort-value=' .. dataSort .. '|\n'
                '' .. damage .. '\n' ..
                ': <span style="color:DodgerBlue"><b>' .. stamina .. '</b></span> Выносливость\n' ..
if damage ~= "" then
                ': <span style="color:crimson"><b>' .. blunt .. '</b></span> Ушибы\n' ..
out = out '' .. damage .. '\n'
                ': <span style="color:darksalmon"><b>' .. piercing .. '</b></span> Уколы\n' ..
end
                ': <span style="color:orange"><b>' .. heat .. '</b></span> Термические\n' ..
if stamina > 0 then
                ': <span style="color:limegreen"><b>' .. radiation .. '</b></span> Радиация\n' ..
out = out .. ': <span style="color:DodgerBlue"><b>' .. stamina .. '</b></span> Выносливость\n'
                ': <span style="color:DarkGray"><b>' .. structural .. '</b></span> Структурные\n'
end
if blunt > 0 then
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
if piercing > 0 then
out = out .. ': <span style="color:darksalmon"><b>' .. piercing .. '</b></span> Уколы\n'
end
if heat > 0 then
out = out .. ': <span style="color:orange"><b>' .. heat .. '</b></span> Термические\n'
end
if radiation > 0 then
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
if structural > 0 then
out = out .. ': <span style="color:DarkGray"><b>' .. structural .. '</b></span> Структурные\n'
end


    -- Параметры  
-- Параметры  
    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'
out = out .. '|style="color:#77c1d9"|<b>' .. caliber .. '</b>\n'


    -- Описание и местоположение
-- Описание
    out = out .. '|\n' .. description .. '\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
-- Местоположение
if location ~= "" then
out = out .. '|\n' .. frame:preprocess('{{SlideMenu|overlay|color=#e1f6ff|title=Список [[File:Examine.svg.192dpi.png|24x24px]]|content=<p></p>\n' .. location .. '}}\n')
else
out = out .. '|\n' .. frame:preprocess('{{FrameText|color=#82d1c4|content=Нет гарантированных мест спавна}}\n')
end
 
out = out .. '|-\n'
 
return out
end
end


return p
return p

Текущая версия от 22:50, 20 сентября 2024

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

local p = {}

-- Функция для создания таблицы с заданными параметрами
function p.templateCells(frame)
	local anchorName = frame.args.anchorName or ""  -- Название якоря
	local itemId = frame.args.itemId or ""  -- ID предмета

	local damage = frame.args.damage or ""
	local stamina = tonumber(frame.args.stamina) or 0
	local blunt = tonumber(frame.args.blunt) or 0
	local slash = tonumber(frame.args.slash) 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 caustic = tonumber(frame.args.caustic) 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 + slash + piercing + heat + radiation + caustic

	-- Формирование строки таблицы
	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'
	
	if damage ~= "" then
		out = out '' .. damage .. '\n'
	end
	if stamina > 0 then
		out = out .. ': <span style="color:DodgerBlue"><b>' .. stamina .. '</b></span> Выносливость\n'
	end
	if blunt > 0 then
		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
	if piercing > 0 then
		out = out .. ': <span style="color:darksalmon"><b>' .. piercing .. '</b></span> Уколы\n'
	end
	if heat > 0 then
		out = out .. ': <span style="color:orange"><b>' .. heat .. '</b></span> Термические\n'
	end
	if radiation > 0 then
		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
	if structural > 0 then
		out = out .. ': <span style="color:DarkGray"><b>' .. structural .. '</b></span> Структурные\n'
	end

	-- Параметры 
	out = out .. '|style="color:DodgerBlue"|<b>' .. fireRate .. '</b>\n'
	out = out .. '|style="color:Yellow"|<b>' .. dps .. '</b>\n'
	out = out .. '|style="color:Aquamarine"|<b>' .. ammunition .. '</b>\n'
	out = out .. '|style="color:#77c1d9"|<b>' .. caliber .. '</b>\n'

	-- Описание
	out = out .. '|\n' .. description .. '\n'

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

	out = out .. '|-\n'

	return out
end

return p