RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Debug DrawingGPU Mesh StructsImGui FFIMath Structs (FFI)FFI C DefinitionsPID ControllersCSV LibraryDelay LineDequeDevelopment UtilitiesEvent ReferenceExtension SystemSignal FiltersGraph PathfindingUI BridgeInput Filter Constants2D Bilinear InterpolationIntrospectionJBeam Pretty PrinterJSON AST ParserSJSON ParserJSON Debug ParserJSON Pretty PrinterK-D Tree (2D Boxes)K-D Tree (3D)K-D Tree (3D)Lua SerializerC++/Lua BindingLua CoreLua ProfilerMath LibraryParticlesQuadtreeSettingsTCP ServerTimer SchedulerUtility Library

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API Referencecommon

CSV Library

Module defined in `lua/common/csvlib.lua`. Provides CSV and TSV creation, writing, and RFC 4180-compliant parsing.

Module defined in lua/common/csvlib.lua. Provides CSV and TSV creation, writing, and RFC 4180-compliant parsing.


Exports

Functions

M.newCSV(...)

Creates a new CSV writer with optional column headers.

  • Parameters:
    • ... - string - Column header names
  • Returns: csvWriter - A CSV writer object with comma delimiter

M.newTSV(...)

Creates a new TSV writer with optional column headers.

  • Parameters:
    • ... - string - Column header names
  • Returns: csvWriter - A TSV writer object with tab delimiter

M.decode(s, sep)

Parses a CSV/TSV string into a 2D table. Handles quoted fields, embedded delimiters, and numeric auto-detection.

  • Parameters:
    • s - string|nil - CSV content to parse
    • sep - string|nil - Single-character delimiter (default: comma)
  • Returns: table - Parsed result

M.readFileCSV(filename, sep)

Reads and parses a CSV file from disk.

  • Parameters:
    • filename - string - Path to CSV file
    • sep - string|nil - Delimiter character
  • Returns: self (module table, for chaining)

csvWriter Methods

writer:add(...)

Appends a row of values. Handles string quoting, number formatting (%.10g), boolean conversion (1/0).

  • Parameters:
    • ... - any - Values for each column
  • Returns: csvWriter - Self (for chaining)

writer:dump()

Returns the accumulated CSV content as a string.

  • Returns: string - Full CSV content

writer:write(filename)

Writes the CSV to a file. Auto-appends datetime suffix if no extension present.

  • Parameters:
    • filename - string|nil - Output filename (defaults to header abbreviation or "csv")
  • Returns: string - Actual filename written

Internal Notes

  • Uses string.buffer for efficient concatenation
  • The decoder handles: quoted strings with escaped quotes, numeric auto-detection, trailing empty row cleanup
  • Writer properly escapes fields containing delimiters, quotes, CR, or LF

See Also

  • cdefDebugDraw Reference - Related reference
  • cdefGpuMesh Reference - Related reference
  • cdefImgui Reference - Related reference
  • Common Libraries Overview - Guide

PID Controllers

Module defined in `lua/common/controlSystems.lua`. Provides PID controller implementations in both parallel and standard forms, commonly used for vehicle systems like cruise control, steering assist,

Delay Line

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

On this page

ExportsFunctionsM.newCSV(...)M.newTSV(...)M.decode(s, sep)M.readFileCSV(filename, sep)csvWriter Methodswriter:add(...)writer:dump()writer:write(filename)Internal NotesSee Also