Модуль:Песочница/Pok: различия между версиями
Материал из Space Station 14 Вики
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 41: | Строка 41: | ||
out = out .. "|-\n" | out = out .. "|-\n" | ||
out = out .. "| " .. cellEvent .. "\n" | out = out .. "| " .. cellEvent .. "\n" | ||
out = out .. "| " .. advert .. "\n" | out = out .. "| {{#invoke:Ftl|main|translation|" .. advert .. "}}\n" | ||
out = out .. " | out = out .. "| " .. description .. "\n" | ||
out = out .. "| " .. characteristicsList .. "\n" | out = out .. "| " .. characteristicsList .. "\n" | ||
break | break | ||
Версия от 19:32, 29 марта 2025
Для документации этого модуля может быть создана страница Модуль:Песочница/Pok/doc
local p = {}
local eventData = mw.loadData("Модуль:IanComradeBot/prototypes/StationEvent.json/data")
function p.stationEvent(frame)
local args = frame.args
local idsStr = args.id or ""
local name = args.name or ""
local image = args.image or "test.png"
local description = args.description or "Нет описания"
local out = ""
local ids = {}
for id in string.gmatch(idsStr, '([^,]+)') do
table.insert(ids, mw.text.trim(id))
end
for _, searchId in ipairs(ids) do
for _, event in ipairs(eventData) do
if event.id == searchId then
local cellEvent = '<div style="text-align:center;">'
cellEvent = cellEvent .. "'''" .. name .. "'''<br>"
cellEvent = cellEvent .. "<span style='color:#adadad'>'''" .. event.id .. "'''</span><br>"
cellEvent = cellEvent .. '[[File:' .. image .. '|64px]]'
cellEvent = cellEvent .. '</div>'
local advert = (event.StationEvent and event.StationEvent.startAnnouncement) or "Нет оповещения"
local characteristicsList = ""
local stationEvent = event.StationEvent or {}
local characteristics = {
{"Вес", "Вес события в системе случайных событий (чем выше, тем чаще случается)", stationEvent.weight},
{"Мин. игроков", "Минимальное количество игроков для начала события", stationEvent.minimumPlayers},
{"Время старта", "Время с которого событие может начаться", (stationEvent.earliestStart and stationEvent.earliestStart .. " сек.")},
{"Длительность", "Длительность события в секундах", (stationEvent.duration and stationEvent.duration .. " сек.")}
}
for _, char in ipairs(characteristics) do
local charValue = char[3] or "Нет"
characteristicsList = characteristicsList .. "- " .. frame:expandTemplate{
title = "AltTooltip",
args = { char[1], char[2] }
} .. ": " .. charValue .. "<br>"
end
out = out .. "|-\n"
out = out .. "| " .. cellEvent .. "\n"
out = out .. "| {{#invoke:Ftl|main|translation|" .. advert .. "}}\n"
out = out .. "| " .. description .. "\n"
out = out .. "| " .. characteristicsList .. "\n"
break
end
end
end
return frame:preprocess(out)
end
return p