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

Add BMS to your Cargo.toml with a language feature:

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

Each BMS release supports one Bevy version, see the compatibility table.

Language Features

LanguageFeature Flag
Lua 5.1lua51
Lua 5.2lua52
Lua 5.3lua53
Lua 5.4lua54
LuaJITluajit
LuaJIT 5.2luajit52
Luauluau
Runerune

Only one Lua feature can be enabled at a time. Lua and Rune can be enabled together.

Bevy Plugin

Add the BMS plugin group to your app:

app.add_plugins(BMSPlugin);

Each plugin in the group can be replaced with a configured one using BMSPlugin.set(MySubPlugin). Next, load and attach your first script.

Extra Features

The default features are core_functions and the ecs, input, math, time, transform, color and window bindings. Disable default features if you only need BMS for script lifecycle management and want to register the bindings yourself.

FeatureDescription
core_functionsThe core functions, i.e. world and the other ways to interact with Bevy via reflection
bevy_<crate>_bindingsBindings for a Bevy crate, i.e. bevy_math_bindings, bevy_transform_bindings. See the [features] of the Cargo manifest for the full list
lua_language_server_filesGenerates Lua language server definitions, see Editor Support
mlua_asyncEnables mlua/async
mlua_serializeEnables mlua/serialize
mlua_macrosEnables mlua/macros
unsafe_lua_modulesLoads every Lua library (debug, LuaJIT’s ffi) and allows native modules via require: scripts are no longer memory safe, see Sandboxing
profile_with_tracyAdds tracy profiling spans

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
Lua 5.1, 5.2, 5.3yesno: the Lua sources call system, which the iOS SDK marks unavailable (fixed upstream in Lua 5.4)
Lua 5.4yesyes
LuaJIT, LuaJIT 5.2yesno: luajit-src can’t build for iOS, which also forbids JIT
Luauyesyes
Runeyesyes

unsafe_lua_modules loads native libraries at runtime, which iOS restricts.