Модуль:gases
| Строка 1: | Строка 1: | ||
local p = {} | |||
p.gases = mw.text.jsonDecode(mw.title.new('Участник:WikiHampter/gas_prototypes.json'):getContent()) | |||
local | local function tablelength(T) | ||
local count = 0 | |||
for _ in pairs(T) do count = count + 1 end | |||
return count | |||
end | |||
local function attachAsNewLine(originalStr, joinStr) | local function attachAsNewLine(originalStr, joinStr) | ||
| Строка 30: | Строка 34: | ||
return effects | return effects | ||
end | end | ||
function p.table(frame) | function p.table(frame) | ||
| Строка 109: | Строка 44: | ||
out = out .. '{| class="wikitable sortable" style="width: 100%; text-align: center;"' | out = out .. '{| class="wikitable sortable" style="width: 100%; text-align: center;"' | ||
out = out .. "\n! Газ !! Описание !! Цвет !! Удельная теплоёмкость (Дж/моль·K) !! Показатель адиабаты !! Молярная масса (г/моль) !! Цена за моль | out = out .. "\n! Газ !! Описание !! Цвет !! Удельная теплоёмкость (Дж/моль·K) !! Показатель адиабаты !! Молярная масса (г/моль) !! Цена за моль !! Эффекты" | ||
local additional = frame.args.additional | local additional = frame.args.additional | ||
| Строка 129: | Строка 64: | ||
end | end | ||
fillGasRow | function fillGasRow(gasId) | ||
local gasPrototype = p.gases[gasId] | local gasPrototype = p.gases[gasId] | ||
local out = "" | local out = "" | ||
| Строка 136: | Строка 71: | ||
local textColor = gasPrototype.textColor or "#FFFFFF" | local textColor = gasPrototype.textColor or "#FFFFFF" | ||
out = out .. '\n|- | out = out .. '\n|- style="background: ' .. color .. '1E; color: ' .. textColor .. '"' | ||
out = out .. '\n! scope="row" style="font-weight: bold;" | ' .. gasPrototype.name | out = out .. '\n! scope="row" style="font-weight: bold;" | ' .. gasPrototype.name | ||
out = out .. '\n| style="text-align: left;" | ' .. gasPrototype.desc | out = out .. '\n| style="text-align: left;" | ' .. gasPrototype.desc | ||
| Строка 144: | Строка 79: | ||
out = out .. '\n| ' .. tostring(gasPrototype.molarMass or "") | out = out .. '\n| ' .. tostring(gasPrototype.molarMass or "") | ||
out = out .. '\n| ' .. tostring(gasPrototype.pricePerMole or "") | out = out .. '\n| ' .. tostring(gasPrototype.pricePerMole or "") | ||
out = out .. '\n| style="text-align: left; font-size: 90%;" | ' .. getEffects(gasPrototype) | out = out .. '\n| style="text-align: left; font-size: 90%;" | ' .. getEffects(gasPrototype) | ||
return out | return out | ||
end | end | ||
| Строка 187: | Строка 104: | ||
out = out .. '<table style="width: 100%; border-collapse: collapse; margin: 10px 0;">' | out = out .. '<table style="width: 100%; border-collapse: collapse; margin: 10px 0;">' | ||
out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Физическое описание</td><td style="padding: 4px 8px;">' .. (gasPrototype.physicalDesc or " | out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Физическое описание</td><td style="padding: 4px 8px;">' .. (gasPrototype.physicalDesc or "—") .. '</td></tr>' | ||
out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Цвет</td><td style="padding: 4px 8px;"><span style="background: ' .. color .. '; color: ' .. textColor .. '; padding: 2px 8px; border-radius: 3px;">' .. color .. '</span></td></tr>' | out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Цвет</td><td style="padding: 4px 8px;"><span style="background: ' .. color .. '; color: ' .. textColor .. '; padding: 2px 8px; border-radius: 3px;">' .. color .. '</span></td></tr>' | ||
out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Удельная теплоёмкость</td><td style="padding: 4px 8px;">' .. (gasPrototype.specificHeat and (gasPrototype.specificHeat .. " Дж/моль·K") or " | out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Удельная теплоёмкость</td><td style="padding: 4px 8px;">' .. (gasPrototype.specificHeat and (gasPrototype.specificHeat .. " Дж/моль·K") or "—") .. '</td></tr>' | ||
out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Показатель адиабаты</td><td style="padding: 4px 8px;">' .. tostring(gasPrototype.heatCapacityRatio or " | out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Показатель адиабаты</td><td style="padding: 4px 8px;">' .. tostring(gasPrototype.heatCapacityRatio or "—") .. '</td></tr>' | ||
out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Молярная масса</td><td style="padding: 4px 8px;">' .. (gasPrototype.molarMass and (gasPrototype.molarMass .. " г/моль") or " | out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Молярная масса</td><td style="padding: 4px 8px;">' .. (gasPrototype.molarMass and (gasPrototype.molarMass .. " г/моль") or "—") .. '</td></tr>' | ||
out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Цена за моль</td><td style="padding: 4px 8px;">' .. (gasPrototype.pricePerMole and (gasPrototype.pricePerMole .. " кредитов") or " | out = out .. '<tr style="border-bottom: 1px solid #ddd;"><td style="font-weight: bold; width: 200px; padding: 4px 8px;">Цена за моль</td><td style="padding: 4px 8px;">' .. (gasPrototype.pricePerMole and (gasPrototype.pricePerMole .. " кредитов") or "—") .. '</td></tr>' | ||
out = out .. '</table>' | out = out .. '</table>' | ||