JBeam Stats
Generates statistics about all JBeam files in the game - part counts, section usage, line counts, and modifier counts.
Generates statistics about all JBeam files in the game - part counts, section usage, line counts, and modifier counts.
Overview
util_jbeamStats scans all .jbeam files and produces aggregate statistics including total files, parts, sections, rows per section, line counts, root parts, and modifier usage. Used by the documentation creator for the official docs.
Extension path: lua/ge/extensions/util/jbeamStats.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
getStats | () | Returns a table of JBeam statistics. |
Internals
Statistics Collected
| Field | Type | Description |
|---|---|---|
totalJbeamFiles | number | Total .jbeam files found. |
partCount | number | Total parts across all files. |
sectionCount | table | Map of section name → occurrence count. |
sectionCountOrdered | array | Sorted {name, count} pairs (descending). |
sectionRowCount | table | Map of section name → total data rows (excludes headers). |
totalLineCount | number | Total lines across all JBeam files. |
totalRootParts | number | Parts with slotType == "main". |
totalModifiersCount | number | Non-array entries in table sections (modifier rows). |
Counting Logic
For each JBeam file:
- Parse JSON content.
- For each part, iterate sections.
- Table sections with array headers: count data rows (subtract 1 for header).
- Non-array entries in table sections count as modifiers.
- Root parts are identified by
slotType == "main".
How It Works
- Call
getStats(). - All
.jbeamfiles are found viaFS:findFiles. - Each file is decoded and analyzed.
- Returns a comprehensive statistics table.
Lua Examples
-- Get JBeam statistics
local stats = extensions.util_jbeamStats.getStats()
print("Total files: " .. stats.totalJbeamFiles)
print("Total parts: " .. stats.partCount)
print("Total lines: " .. stats.totalLineCount)
print("Root parts: " .. stats.totalRootParts)
-- Write to file for documentation
jsonWriteFile('jbeam_stats.json', stats, true)
-- Check most common sections
for _, entry in ipairs(stats.sectionCountOrdered) do
print(entry[1] .. ": " .. entry[2])
endAdditional Exports
M.getStats- (undocumented)
Instanced Line Render Demo
Demo extension showcasing the instanced line and dot rendering API. Features an N-body gravity simulation, grid drawing, sine waves, edge tests, and traffic signal visualization.
Log Streams
Simple file I/O helper for reading and writing logged stream data in JSON, wikitable, and reStructuredText formats.