The Lua Environment (Advanced)

By default, the O3DE component entity Lua environment is a single Lua environment \(or `lua_State`\). This environment is bound to the BehaviorContext that is owned by the ComponentApplication. Because of this, it has access to all API operations that are reflected on startup.

Adding other VMs

You may add more ScriptContext instances using the ScriptSystemBus \(either call `AddContextWithId`, or create your own and call `AddContext`\). If you want your new context to be available for debugging, you must register it with ScriptDebugAgentBus::RegisterContext.

Reusing code

Lua provides the capability to load and execute scripts from other Lua files using the built-in Lua require function. It’s important to note that this function requires a special path format. The file path is delimited by periods instead of slashes, has no .lua file name extension, and is relative to the O3DE assets directory. For example, if you want to use the require function to give your scripts some common functionality from the project’s Scripts directory, you can use code similar to the following example.

local library = require("Scripts.MyLibraryFile")

Copyright © 2026 DawnEngine. All rights reserved.

DawnEngine is a commercial 3D engine distributed under the DawnEngine end-user license agreement. Engine binaries and source are proprietary and are not covered by the licenses below.

Documentation only: the prose and templates on this site are a derivative work of Open 3D Engine (O3DE) documentation by the O3DE Contributors, used under CC BY 4.0 (documentation content), Apache 2.0 (site code), and the MIT license (inline code samples).

The open-source 3D engine that DawnEngine is built on top of is Open 3D Engine . DawnEngine is not affiliated with, endorsed by, or sponsored by The Linux Foundation or the O3DE project. “O3DE” and “Open 3D Engine” are trademarks of The Linux Foundation.