mention app dev in docs
Some checks failed
Rust / build (pull_request) Has been cancelled

This commit is contained in:
Jaroslaw Konik 2025-05-26 17:04:52 +02:00
parent 35dc89322e
commit 2d2ba975bb
8 changed files with 29 additions and 25 deletions

View file

@ -6,9 +6,9 @@ edition = "2024"
license = "MIT OR Apache-2.0"
readme = "README.md"
categories = ["game-development"]
description = "Plugin for Bevy engine that allows you to write some of your game logic in a scripting language"
description = "Plugin for Bevy engine that allows you to write some of your game or application logic in a scripting language"
repository = "https://github.com/jarkonik/bevy_scriptum"
keywords = ["bevy", "rhai", "scripting", "game", "gamedev"]
keywords = ["bevy", "lua", "scripting", "game", "script"]
[features]
lua = ["dep:mlua", "mlua/luajit"]

View file

@ -2,7 +2,7 @@
![demo](demo.gif)
bevy_scriptum is a a plugin for [Bevy](https://bevyengine.org/) that allows you to write some of your game logic in a scripting language.
bevy_scriptum is a a plugin for [Bevy](https://bevyengine.org/) that allows you to write some of your game or application logic in a scripting language.
Currently [Rhai](https://rhai.rs/) and [Lua](https://lua.org/) are supported, but more languages may be added in the future.
Everything you need to know to get started with using this library is contained in the

View file

@ -1,6 +1,6 @@
# bevy_scriptum 📜
bevy_scriptum is a a plugin for [Bevy](https://bevyengine.org/) that allows you to write some of your game logic in a scripting language.
bevy_scriptum is a a plugin for [Bevy](https://bevyengine.org/) that allows you to write some of your game or application logic in a scripting language.
Currently [Rhai](https://rhai.rs/) and [Lua](https://lua.org/) are supported, but more languages may be added in the future.
API docs are available in [docs.rs](https://docs.rs/bevy_scriptum/latest/bevy_scriptum/)

View file

@ -9,18 +9,18 @@ within bevy dependency in `Cargo.toml`
bevy = { version = "0.16", features = ["file_watcher"] }
```
## Init-teardown pattern for game development
## Init-teardown pattern
It is useful to structure your game in a way that would allow making changes to
the scripting code without restarting the game.
It is useful to structure your application in a way that would allow making changes to
the scripting code without restarting the application.
A useful pattern is to hava three functions "init", "update" and "teardown".
- "init" function will take care of starting the game(spawning the player, the level etc)
- "init" function will take care of starting the application(spawning the player, the level etc)
- "update" function will run the main game logic
- "update" function will run the main application logic
- "teardown" function will despawn all the entities so game starts at fresh state.
- "teardown" function will despawn all the entities so application starts at fresh state.
This pattern is very easy to implement in bevy_scriptum. All you need is to define all needed functions
in script:
@ -35,7 +35,7 @@ local function init()
player.entity = spawn_player()
end
-- game logic here, should be called in a bevy system using call_fn
-- application logic here, should be called in a bevy system using call_fn
local function update()
(...)
end
@ -45,7 +45,7 @@ local function teardown()
despawn(player.entity)
end
-- call init to start the game, this will be called on each file-watcher script
-- call init to start the application, this will be called on each file-watcher script
-- reload
init()
```

View file

@ -4,7 +4,7 @@ use bevy_scriptum::runtimes::lua::prelude::*;
fn main() {
App::new()
// This is just needed for headless console app, not needed for a regular bevy game
// This is just needed for headless console app, not needed for a regular bevy application
// that uses a winit window
.set_runner(move |mut app: App| {
loop {

View file

@ -4,12 +4,14 @@ use bevy_scriptum::runtimes::rhai::prelude::*;
fn main() {
App::new()
// This is just needed for headless console app, not needed for a regular bevy game
// This is just needed for headless console app, not needed for a regular bevy application
// that uses a winit window
.set_runner(move |mut app: App| loop {
app.update();
if let Some(exit) = app.should_exit() {
return exit;
.set_runner(move |mut app: App| {
loop {
app.update();
if let Some(exit) = app.should_exit() {
return exit;
}
}
})
.add_plugins(DefaultPlugins)

View file

@ -4,12 +4,14 @@ use bevy_scriptum::runtimes::ruby::prelude::*;
fn main() {
App::new()
// This is just needed for headless console app, not needed for a regular bevy game
// This is just needed for headless console app, not needed for a regular bevy application
// that uses a winit window
.set_runner(move |mut app: App| loop {
app.update();
if let Some(exit) = app.should_exit() {
return exit;
.set_runner(move |mut app: App| {
loop {
app.update();
if let Some(exit) = app.should_exit() {
return exit;
}
}
})
.add_plugins(DefaultPlugins)

View file

@ -1,6 +1,6 @@
//! ![demo](demo.gif)
//!
//! bevy_scriptum is a a plugin for [Bevy](https://bevyengine.org/) that allows you to write some of your game logic in a scripting language.
//! bevy_scriptum is a a plugin for [Bevy](https://bevyengine.org/) that allows you to write some of your game or application logic in a scripting language.
//! Currently [Rhai](https://rhai.rs/) and [Lua](https://lua.org/) are supported, but more languages may be added in the future.
//!
//! Everything you need to know to get started with using this library is contained in the
@ -15,7 +15,7 @@
//! - flexibility
//! - hot-reloading
//!
//! Scripts are separate files that can be hot-reloaded at runtime. This allows you to quickly iterate on your game logic without having to recompile your game.
//! Scripts are separate files that can be hot-reloaded at runtime. This allows you to quickly iterate on your game or application logic without having to recompile your game.
//!
//! All you need to do is register callbacks on your Bevy app like this:
//! ```no_run