Модуль:Prototypes/Механика/Растение
Версия от 15:54, 23 июля 2025; Pok (обсуждение | вклад) (Новая страница: «local p = {} local function kelvinToCelsius(kelvin) return kelvin - 273.15 end function p.main(frame) local data = mw.loadData("Модуль:IanComradeBot/prototypes/seeds.json/data") local header = [[ {|id="BOTANY" class="wikitable sortable mw-collapsible" style="width:100%;margin:0;" |- ! rowspan="2" style="width:10%;" | Плод ! rowspan="2" class="unsortable" style="width:5%;" | Семена ! rowspan="2" class="unsortable" style="wid...»)
Для документации этого модуля может быть создана страница Модуль:Prototypes/Механика/Растение/doc
local p = {}
local function kelvinToCelsius(kelvin)
return kelvin - 273.15
end
function p.main(frame)
local data = mw.loadData("Модуль:IanComradeBot/prototypes/seeds.json/data")
local header = [[
{|id="BOTANY" class="wikitable sortable mw-collapsible" style="width:100%;margin:0;"
|- ! rowspan="2" style="width:10%;" | Плод
! rowspan="2" class="unsortable" style="width:5%;" | Семена
! rowspan="2" class="unsortable" style="width:5%;" | Растение
! colspan="3" class="unsortable" style="width:20%;" id="no-highlight" | Характеристики
! rowspan="2" class="unsortable" style="width:20%;" | Содержит вещества
! rowspan="2" style="width:20%;" | Мутации
|- ! style="width:10%;" class="unsortable" | Рост
! style="width:10%;" class="unsortable" | Условия
! style="width:10%;" class="unsortable" | Тип сбора
]]
local rows = {}
for _, seed in ipairs(data) do
local fruitImg = string.format("{{Предмет|(%s)|size=64px|vertical=1|imageTooltip=1|link={{#invoke:Entity Lookup|getname|(%s)}}}}", seed.packetPrototype, seed.packetPrototype)
local seedImg = string.format("{{Предмет|(%s)|size=64px|vertical=1|imageTooltip=1|link={{#invoke:Entity Lookup|getname|(%s)}}}}", seed.id, seed.id)
local plantImg = string.format("{{Предмет|(%s)-harvest|size=64px|vertical=1|imageTooltip=1|link={{#invoke:Entity Lookup|getname|(%s)}}}}", seed.id, seed.id)
local characteristics = string.format(
[[Потенция: %d <br> Урожайность: %d <br> Время жизни: %d <br> Созревания: %d <br> Продуктивность: %d <br> Стадии роста: %d]],
seed.potency, seed.yield, seed.lifespan, seed.maturation, seed.production, seed.growthStages or 0
)
local heatC = kelvinToCelsius(seed.idealHeatKelvin or 273.15)
local conditions = string.format(
[[Вода: %s <br> Удобрения: %s <br> Температура: %.2f <br> Освещения: %s]],
seed.waterConsumption or "-", seed.nutrientConsumption or "-", heatC, seed.idealLight or "-"
)
local harvestType = seed.harvestRepeat and tostring(seed.harvestRepeat) or "-"
local chemList = {}
if seed.chemicals then
for chem, vals in pairs(seed.chemicals) do
table.insert(chemList, string.format("* %s (Min: %s, Max: %s, Divisor: %s)", chem, vals.Min, vals.Max, vals.PotencyDivisor))
end
end
local chems = table.concat(chemList, '<br>')
local mutList = {}
if seed.mutationPrototypes then
for _, mu in ipairs(seed.mutationPrototypes) do
table.insert(mutList, string.format("* {{Предмет|(%s)|link=}}", mu))
end
end
local muts = table.concat(mutList, '<br>')
local row = string.format(
[[|-
| %s || %s || %s || %s || %s || %s || %s || %s]],
fruitImg, seedImg, plantImg, characteristics, conditions, harvestType, chems, muts
)
table.insert(rows, row)
end
local footer = '|}'
return header .. table.concat(rows, '\n') .. '\n' .. footer
end
return p