bevy_scriptum/examples/js/non_closure_system.rs
Jaroslaw Konik 36cc907f0e
Some checks failed
Book / test (pull_request) Has been cancelled
Rust / build (3.4.4, map[os:ubuntu-latest]) (pull_request) Has been cancelled
Implement JavaScript runtime
2026-06-04 23:50:53 +02:00

23 lines
645 B
Rust

use bevy::prelude::*;
use bevy_scriptum::prelude::*;
use bevy_scriptum::runtimes::javascript::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_scripting::<JsRuntime>(|runtime| {
runtime.add_function(String::from("hello_bevy"), hello_bevy_callback_system);
})
.add_systems(Startup, startup)
.run();
}
fn startup(mut commands: Commands, assets_server: Res<AssetServer>) {
commands.spawn(Script::<JsScript>::new(
assets_server.load("examples/js/hello_world.js"),
));
}
fn hello_bevy_callback_system() {
println!("hello bevy, called from script");
}