Skip to main content

Crate bevy_scripting_rune

Crate bevy_scripting_rune 

Source
Expand description

stable pipeline dev/1 pipeline docs crates.io

§bevy_scripting_rune

Simple integration of rune for bevy.

§Compatibility

bevybevy_scripting_rune
0.180.6
0.170.5
0.160.2-0.4
0.150.1

§Example

use bevy::prelude::*;
use bevy_scripting_rune::prelude::*;

fn setup(
    asset_server: Res<AssetServer>,
    script_assets: Res<Assets<bevy_scripting_rune::Script>>,
    mut executor: ResMut<bevy_scripting_rune::Executor>,
)
{
    let handle = asset_server.load("test.rn");
    let script = script_assets.get(&handle).unwrap();
    executor.load_script(script);
    executor.build().unwrap();
}

fn run(executor: Res<bevy_scripting_rune::Executor>)
{
    let r = executor.call::<i32>("plus", (38, 4)).unwrap();
    println!("r = {}", r);
}

fn main()
{
    App::new()
        .add_plugins((
            DefaultPlugins,
            DefaultScriptingRunePlugin::default(),
        ))
        .add_systems(Startup, setup)
        .add_systems(Update, run);

}

A more complex example is available in example/example.rs.

Re-exports§

pub use rune;

Modules§

prelude
Important types to conveniently import.
protocol
protocol module for communication between game and rune scripts.
value
Value module.

Structs§

Executor
Executor resource to run scripts.
Script
Script asset for a rune script.
ScriptingRunePlugin
Plugin for adding support to scripting with rune. TGameMessage is the type used to send messages from the Game to listeners writen in Rust. TScriptMessage is the type used to send messages from Rust scripts to the Game. Usage

Type Aliases§

DefaultScriptingRunePlugin
Plugin for adding support to scripting with rune. Using dummy message type for protocol.