Source code for CSP Lua libraries. Feel free to use any of its parts, like its class implementation, in your projects, or just use it for a reference.
Designed to work with OpenResty’s fork of LuaJIT, with LuaJIT compiled with 5.2 compatibility option.
Whole API is fully documented, documentation definitions are shipped with CSP builds and can be found in “extension/internal/lua-sdk” folder, with a readme file on how to plug them in. You’d need to use Visual Studio Code and Lua plugin by sumneko, and it would result in a neat seamless docs integration:
Definition files are generated in EmmyLua format, and there are plugins for other IDEs too, but it might be a bit more tricky to set.
More information is available in wiki.
Any Lua script in Assetto Corsa first loads ac_common library and then loads a library corresponding to its type.
Different types of script can define different script.…
functions which will then be called by CSP when certain event occurs.
For backwards compatibility some functions, like function script.update()
, can be defined in global namespace like function update()
,
but script.…
ones will be looked for first. Once CSP finds a function, it would store a reference to it for faster lookup when calling
in the future, so changing functions on-fly wouldn’t work.
A few places in this repo that might interest you:
- Definitions: while automatically generated documentation for that Lua plugin is detaile, there are also some simple summary files listing available functions and structures. They’re not as exhaustive and don’t have everything, but they still might help to skim over and possibly notice something useful.
- Common API implementation: sometimes docs might not be enough and you might want to check how something is implemented, like, for example, those
table
functions.