Module:OOOInfoBox: Difference between revisions

No edit summary
No edit summary
Line 124: Line 124:


   -- Basics
   -- Basics
  add_row(box, 'Domain', domain)
add_group(box, 'General', {
   add_row(box, 'Art Number', art)
   {'Category',  pick(args, data, 'category')},
   add_row(box, 'Type', pick(args, data, 'type'))
   {'Subcategory',pick(args, data, 'subcategory')},
  {'Price',     pick(args, data, 'price')},
  {'Art Number', art},
  {'Domain',    domain},
})


  -- Performance / Power
-- Performance (auto-hides if empty)
  add_group_header(box, 'Performance')
add_group(box, 'Performance', {
   add_row(box, 'Throughput (m³/h)', pick(args, data, 'throughput_m3h'))
   {'Throughput (m³/h)', pick(args, data, 'throughput_m3h')},
  add_row(box, 'Power (kW)', with_unit(pick(args, data, 'power_kw'), U.kw))
   {'Capacity',         pick(args, data, 'capacity')},
   add_row(box, 'Capacity', pick(args, data, 'capacity'))
})


   -- I/O (mergers/splitters etc.)
-- Power (keep separate from Performance; easy to add more later)
   local belt_in = pick(args, data, 'beltInputs')
add_group(box, 'Power', {
   local belt_out = pick(args, data, 'beltOutputs')
  {'Power (kW)', with_unit(pick(args, data, 'power_kw'), U.kw)},
   local pipe_in = pick(args, data, 'pipeInputs')
   -- Example for later: {'Generated (MW)', with_unit(pick(args, data, 'power_generated_mw'), U.mw)},
   local pipe_out = pick(args, data, 'pipeOutputs')
})
  if belt_in or belt_out or pipe_in or pipe_out then
 
    add_group_header(box, 'I/O')
-- I/O (mergers/splitters etc.)
    add_row(box, 'Conveyor inputs', belt_in)
add_group(box, 'I/O', {
    add_row(box, 'Conveyor outputs', belt_out)
   {'Conveyor inputs', pick(args, data, 'beltInputs')},
    add_row(box, 'Pipeline inputs', pipe_in)
   {'Conveyor outputs', pick(args, data, 'beltOutputs')},
    add_row(box, 'Pipeline outputs', pipe_out)
   {'Pipeline inputs', pick(args, data, 'pipeInputs')},
  end
   {'Pipeline outputs', pick(args, data, 'pipeOutputs')},
})
 
-- Dimensions: supports size={x,y,z} and compact/expanded modes
local sx, sy, sz
if data.size and type(data.size) == 'table' then
  sx, sy, sz = data.size.x, data.size.y, data.size.z
end
local size_w    = pick(args, data, 'size_width') or sx
local size_l    = pick(args, data, 'size_length') or sy
local size_h    = pick(args, data, 'size_height') or sz
local size_note = pick(args, data, 'size_note')


  -- Dimensions (with tiny tooltip like their wiki)
local dims_mode = (args.dimensions or ''):lower() -- "compact" or "expanded"
  local size_w = pick(args, data, 'size_width')
if dims_mode == '' then dims_mode = 'compact' end  -- default: compact line
  local size_l = pick(args, data, 'size_length')
  local size_h = pick(args, data, 'size_height')
  local size_note = pick(args, data, 'size_note')


   if size_w or size_l or size_h or size_note then
if dims_mode == 'compact' then
     add_group_header(box, 'Dimensions')
  local function fmt(x) return x and tostring(x) or '' end
    add_row(box, 'Width',  with_unit(size_w, U.m), 'Measured outer width')
  local compact = nil
    add_row(box, 'Length', with_unit(size_l, U.m), 'Measured outer length')
   if size_w or size_l or size_h then
    add_row(box, 'Height', with_unit(size_h, U.m), 'Measured to highest point')
     compact = table.concat({fmt(size_w), '×', fmt(size_l), (size_h and '×' or ''), fmt(size_h)}, '')
     if tonumber(size_w) and tonumber(size_l) then
     compact = mw.text.trim(compact)
      local area = tonumber(size_w) * tonumber(size_l)
    if compact ~= '' then compact = compact .. U.m end
      add_row(box, 'Area', with_unit(area, U.m2))
    end
    add_row(box, 'Note', size_note)
   end
   end
  add_group(box, 'Dimensions', {
    {'Overall', compact, 'Width × Length × Height'},
    {'Note',    size_note},
  })
else
  add_group(box, 'Dimensions', {
    {'Width',  with_unit(size_w, U.m), 'Measured outer width'},
    {'Length', with_unit(size_l, U.m), 'Measured outer length'},
    {'Height', with_unit(size_h, U.m), 'Measured to highest point'},
    (tonumber(size_w) and tonumber(size_l))
      and {'Area', with_unit(tonumber(size_w)*tonumber(size_l), U.m2)}
      or nil,
    {'Note', size_note},
  })
end


   out:node(box)
   out:node(box)