Skip to content

AIMWARE Lua API Docs

Welcome

These pages contain an exhaustive documentation useful for customers and developers

If you have any question regarding the API, visit the Lua Scripting forum

Introduction

All our software tagged as V5 ship with a Lua scripting language that expose new classes and libraries that allow users to extend the existing features or create new one

If you are new with the Lua scripting language, the Lua Docs and the examples inside this knowledge base are the perfect start

To write the code you can use the built-in editor or use any text editor of your choice

Warning

Encoding errors might happen on some systems

Select UTF-8 encoding in your favorite IDE

Note

You should keep most of your scripts functions and variables as local to avoid collision with other scripts

Global variables should only be used to write libraries or scripts that interact with each other

Load a script

In order to load a Lua script you have multiple options depending on the use case

Your editor of choice

  • Click Open Settings Folder from Settings->Advanced tab in the Cheat Menu
  • Make new file called example.lua
  • Paste one of the scripts you want into the file
  • Save it then click Refresh under Lua Scripts list in menu
  • Select the script from list and press Load

Console

Open CONSOLE tab in cheat menu and then write the following:

lua.run "print('Hello from lua')"       --To run lua script directly
lua.load script.lua                     --To run lua script from file

Automatically Run Luas

Select the script and click Set As Autorun

This will set the script to be loaded automatically every time the software is loaded

Register a callback

In short terms a callback is a function that will be invoked at a specific point in time

This will allow you to execute specific logic at the right stage

Registering a callback is done by using callbacks.Register from the Callbacks library

Note

Read more about the callbacks.Register