Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

Cargo

First you need to install the crate by adding this entry to your Cargo.toml dependencies list:

bevy_mod_scripting = { version = "0.9.0", features = ["lua54"]}

Choose the language features you wish enabled and add them to the features block.

Bevy Plugin

The next step is to add the BMS plugin to your application.

app.add_plugins(BMSPlugin);

You can modify each of the plugins contained within the plugin group using set(MySubPlugin).

Language Features

Each language supported by BMS can be switched-on via feature flag as below:

LanguageFeature Flag
Lua51lua51
Lua52lua54
Lua53lua53
Lua54lua54
Luajitluajit
Luajit52luajit52
Luauluau
Runerune

Mobile

CI type-checks bevy_mod_scripting for aarch64-linux-android and aarch64-apple-ios; nothing is run on a device. Both need the target’s C toolchain (Android NDK, Xcode) as the Lua runtimes are built from source, and Android needs a bevy activity feature in your app (e.g. bevy/android-native-activity).

LanguageAndroidiOS
Lua51, Lua52, Lua53yesno: the Lua sources call system, which the iOS SDK marks unavailable (fixed upstream in Lua 5.4)
Lua54yesyes
Luajit, Luajit52yesno: luajit-src can’t build for iOS, which also forbids JIT
Luauyesyes
Runeyesyes

unsafe_lua_modules loads native libraries at runtime, which iOS restricts.

Extra Features

In order to fit as many use cases as possible, BMS allows you to disable a lot of its functionality.

By default all of the useful features are enabled, but you may disable them if you wish if you are only needing BMS for script lifecycle management, and want to populate the bindings yourself.

FeatureDescription
core_functionsIf enabled, will enable all core functions, i.e. bevy integrations which let you interact with Bevy via reflection
bevy_<bevy_crate>_bindingsenables bindings for the specified bevy crate, e.g. bevy_ecs, bevy_transform, bevy_pbr etc. for a full list of available modules check out The Cargo manifest
mlua_asyncEnables mlua/async
mlua_serializeEnables mlua/serialize
mlua_macrosEnables mlua/macros
unsafe_lua_modulesAllows loading unsafe modules via require in lua