Module:OOOInfoBox: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 237: | Line 237: | ||
{'Price', format_price(pick(args,data,'price'))}, | {'Price', format_price(pick(args,data,'price'))}, | ||
}) | }) | ||
-- ------------------------------------------------------------------------- | |||
-- Vehicle | |||
-- ------------------------------------------------------------------------- | |||
local function format_capacity(v) | |||
local n = tonumber(v) | |||
if not n then return v end | |||
return string.format("%.1f%s", n/1000, U.m3) | |||
end | |||
local function format_fuel_use(v) | |||
local n = tonumber(v) | |||
if not n or n < 0 then return nil end | |||
return tostring(n) .. " L/h" | |||
end | |||
local function format_fuel_capacity(v) | |||
local n = tonumber(v) | |||
if not n then return nil end | |||
return tostring(n) .. " L" | |||
end | |||
local function format_weight(v) | |||
local n = tonumber(v) | |||
if not n then return v end | |||
local s = tostring(math.floor(n)) | |||
s = s:reverse():gsub("(%d%d%d)", "%1 "):reverse():gsub("^ ", "") | |||
return s .. " kg" | |||
end | |||
add_group(box,'Vehicle Details',{ | |||
{'Unlock Level', pick(args,data,'level')}, | |||
{'Weight', format_weight(pick(args,data,'weight'))}, | |||
{'Capacity', format_capacity(pick(args,data,'capacity'))}, | |||
{'Fuel Tank', format_fuel_capacity(pick(args,data,'fuelCapacity'))}, | |||
{'Fuel Usage', format_fuel_use(pick(args,data,'fuelBaseUse'))}, | |||
}) | |||
-- ------------------------------------------------------------------------- | -- ------------------------------------------------------------------------- | ||
| Line 250: | Line 288: | ||
-- ------------------------------------------------------------------------- | -- ------------------------------------------------------------------------- | ||
if domain ~= 'Vehicles' then | |||
add_group(box,'Performance',{ | add_group(box,'Performance',{ | ||
{'Throughput (m³/h)', pick(args,data,'throughput_m3h')}, | {'Throughput (m³/h)', pick(args,data,'throughput_m3h')}, | ||
{'Capacity', pick(args,data,'capacity')}, | {'Capacity', pick(args,data,'capacity')}, | ||
}) | }) | ||
end | |||
-- ------------------------------------------------------------------------- | -- ------------------------------------------------------------------------- | ||