delayLine Reference
Module defined in `lua/common/delayLine.lua`. Implements a time-based delay buffer for queuing data packets that arrive at one end and exit after a fixed time delay. Originally designed for simulating
Module defined in lua/common/delayLine.lua. Implements a time-based delay buffer for queuing data packets that arrive at one end and exit after a fixed time delay. Originally designed for simulating fuel travel time through exhaust pipes.
Exports
Functions
delayLine.new(delay)
Creates a new delay line with a fixed time delay.
- Parameters:
delay- number - The time in seconds each data packet is delayed
- Returns: table - A delay line object
Instance Methods
line:push(payload)
Pushes a data packet into the delay line. It will be available for retrieval after the configured delay.
- Parameters:
payload- any - Data to push through the delay line
line:pop(dt)
Advances time by dt and returns all data packets that have completed their delay.
- Parameters:
dt- number - Delta time in seconds
- Returns: table|nil - Array of delayed payloads that reached the end, or nil if empty
line:popSum(dt)
Like pop, but sums all arriving numeric payloads instead of returning them individually.
- Parameters:
dt- number - Delta time in seconds
- Returns: number - Sum of all numeric payloads that arrived (0 if none)
line:peek(dt)
Previews which payloads would arrive within the next dt seconds, without consuming them.
- Parameters:
dt- number - Time window to preview
- Returns: table|nil - Array of payloads that would arrive, or nil if empty
line:reset()
Clears all pending data and resets the internal clock to 0.
Internal Notes
- Each pushed item gets timestamped with
currentTime + delay - Internal state:
data(payload array),times(timestamp array),length,currentTime popSumbreaks out of the loop early when it finds a non-expired item (assumes chronological order)
csvlib Reference
Module defined in `lua/common/csvlib.lua`. Provides CSV and TSV creation, writing, and RFC 4180-compliant parsing.
dequeue Reference
Module defined in `lua/common/dequeue.lua`. Double-ended queue (deque) implementation supporting push/pop from both ends, rotation, removal, and iteration. Based on Pierre Chapuis's library.