Skip to content

Getting Started with CSP Lua Scripting

CheesyManiac edited this page Apr 29, 2023 · 2 revisions

Welcome

You're probably here because you're interested in creating stuff using the Lua Scripting functionality that is part of Custom Shaders Patch for Assetto Corsa.

I'm going to run through as many of the basics as I can to get you started. I will NOT be covering how to code, that is your own adventure.

General Steps

  1. Download CSP 1.76 or newer

    This was the first major release that publicly opened Lua scripting.

    (NOTE: I would always recommend using the latest non-preview build for public development)

  2. Install CSP into your AC install

  3. Navigate to \assettocorsa\extension\internal\lua-sdk

    Here you will find all the libraries specific to the script you want to make. It is VITAL you know how to use the control + F (aka search) function in your text editor, 90% of answers is one search away. If you can't find a value, or a function, it won't be available for that script type.

  4. Read the README.md file

  5. Ensure the Lua Debug app is enabled in CSP > GUI > Developer Apps

    image

    You will then find this in-game at the bottom of the new app taskbar.

    image

    Once opened, it will show you:

    • a) If your script is running
    • b) Any errors it may have
    • c) Live debug, logs, and performance

Important Wiki Pages

  • CSP Lua Apps

    How to get create a Lua app.

  • CSP Lua Server Scripts

    The config required as part of the CSP Server Extra Options in order for clients to use the server scripts. Extra values here

Useful Resources

  • CSP Lua Source

    Useful if you want to understand how most functions work internally. This is usually behind on CSP Preview build libraries which come in their own download.

  • CSP Lua Examples

    These contain some light examples of different script types. I will covering the same thing in more detail in other pages.

  • Internal CSP apps

    These are found here \assettocorsa\extension\internal\lua-apps You can edit them locally to effect the in-game app. Note, they will be reverted if you change/reinstall CSP

  • CSP Paintshop App

    This is a showcase of the CSP Lua API and what is possible. It works well and is good for showcasing some advanced functions. It is imperative that you read the README on how to install it.