diff --git a/Cargo.toml b/Cargo.toml index 18a91a9..bdb8424 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -190,6 +190,11 @@ name = "function_return_value_ruby" path = "examples/ruby/function_return_value.rs" required-features = ["ruby"] +[[example]] +name = "hello_world_ruby" +path = "examples/ruby/hello_world.rs" +required-features = ["ruby"] + [dev-dependencies] tracing-subscriber = "0.3.18" diff --git a/assets/examples/ruby/hello_world.rb b/assets/examples/ruby/hello_world.rb new file mode 100644 index 0000000..7f4cbfd --- /dev/null +++ b/assets/examples/ruby/hello_world.rb @@ -0,0 +1 @@ +hello_bevy() diff --git a/examples/ruby/hello_world.rs b/examples/ruby/hello_world.rs new file mode 100644 index 0000000..218067c --- /dev/null +++ b/examples/ruby/hello_world.rs @@ -0,0 +1,21 @@ +use bevy::prelude::*; +use bevy_scriptum::prelude::*; +use bevy_scriptum::runtimes::ruby::prelude::*; + +fn main() { + App::new() + .add_plugins(DefaultPlugins) + .add_scripting::(|runtime| { + runtime.add_function(String::from("hello_bevy"), || { + println!("hello bevy, called from script"); + }); + }) + .add_systems(Startup, startup) + .run(); +} + +fn startup(mut commands: Commands, assets_server: Res) { + commands.spawn(Script::::new( + assets_server.load("examples/ruby/hello_world.rb"), + )); +}