IN THIS ARTICLE
Writing Lua Scripts in Open 3D Engine
You can use Lua in Open 3D Engine (O3DE) to facilitate quick iteration of your game project. Lua is a powerful, fast, lightweight, embeddable scripting language. When you construct new gameplay and game systems, you can run your changes immediately, without compiling your source code.
O3DE uses Lua version 5.4 .
The Lua development environment in O3DE includes the Lua Editor. The debugger that is included with the Lua Editor uses a connection hub called GridHub. These two applications are built when the O3DE Editor is built.
To build Lua Editor and GridHub separately, navigate to the directory where you build your project (or where you build the O3DE engine, if you build the engine separately) and run the following command, inserting the path to your build directory.
cmake --build <build-directory> --target LuaIDE GridHub --config profile -- -m
For learning the Lua language itself, the lua.org website is a good place to start.
- Official Lua Documentation - Provides a central location for information about Lua, including a Getting started page.
- Programming in Lua - This text is a resource for getting started with Lua programming.
- Lua 5.4 Reference Manual - Provides a reference of all the functions that are available by default in Lua.
After you read through this tutorial on writing Lua scripts for the component entity system, learn more about using Lua in O3DE by consulting the following resources.
- For information on O3DE’s built-in Lua editor, refer to Lua Editor .
- For information about the O3DE EBus, refer to Working with the Event Bus (EBus) system .
|Adding Lua Scripts to Component Entities||Use the Lua Script component to add script functionality to your game entities.|
|Lua Script Structure||Basic structure of a Lua script.|
|Lua Editor||Learn about the Lua Editor.|
|Properties Table||Specify the properties of a Lua script component that appear in O3DE Editor.|
|Using EBuses in Lua||Write Lua scripts that use the EBus to communicate between components.|
|The Lua Environment (Advanced)||Learn about adding ScriptContext instances and using common code in the O3DE Lua environment.|
|Debugging Lua Scripts||Learn about debugging Lua scripts in O3DE.|
|Debugging with Lua Editor||Use Lua Editor to debug Lua scripts.|
|Camera Component||Use the Camera component to allow an entity to be used as a camera.|
|Using Player Input||Work with the Input component in O3DE.|
|Input Component Event Bus Interface||Work with the Input component EBus (event bus).|
|AWS Client Auth Scripting||Examples of using the AWS Client Auth Gem with Script Canvas and Lua.|
|AWS Metrics Scripting||Examples of using Script Canvas or Lua with the AWS Metrics Gem to generate and submit metrics.|
|Gestures Gem||The Gestures Gem provides detection for common gesture-based input actions.|
|Virtual Gamepad Gem||The Virtual Gamepad Gem provides controls that emulate a gamepad on touch screen devices for O3DE projects.|
|Tweener Lua Script||Learn how to use Lua scripting to animate your entities with the Scripted Entity Tweener system.|
|Tweener Timeline||Use Scripted Entity Tweener’s timeline abilities to chain animations together and exert fine control over them.|
|Synchronizing Animation Graphs||Use synchronized animation graphs to synchronize animation between actors.|