The Custom Shaders Patch (CSP) Lua API is a massive extension of the Assetto Corsa engine.
It allows developers to write high-performance logic that interacts with almost every system in the game,
from the way light bounces off a car’s paint to the way AI drivers navigate a track.
Ilja Jusupov (x4fab)
The CSP Lua SDK is developed and maintained by Ilja Jusupov, also known as
x4fab. As the lead developer of Custom Shaders Patch and Content Manager,
Ilja transformed Assetto Corsa from a static 2014 racing simulator into a
dynamic, modern platform. The Lua API is his solution for allowing the
community to add features that would otherwise require access to the game’s
original C++ source code.
Assetto Corsa was originally built using C++ and Python. However,
Python in AC is limited to basic UI and some telemetry data. CSP introduces LuaJIT for several key reasons:
Performance
LuaJIT is significantly faster than standard Python, making it capable of
running logic within the physics engine without causing lag.
Direct Memory Access
The SDK uses Foreign Function Interfaces to communicate directly to the
game’s memory, allowing for integration with the engine’s core.
Hot Reloading
Unlike C++ plugins, Lua scripts can be reloaded instantly while the game is
running, drastically speeding up development time.
The scope of the API is divided into several contexts. Depending on where your script is placed, you can create:
- Custom HUDs
- New Game Modes
- Physics Modifications
- Visual FX: Scripted lights, dynamic weather behavior, and animated track elements.
-
Assetto Corsa provides the base physics and rendering pipeline.
-
CSP (Custom Shaders Patch) injects itself into the engine process.
-
The Lua SDK provides the bindings, the functions like ac.getCar(),
that allow your Lua code to tell the C++ engine what to do.