add example

This commit is contained in:
Jaroslaw Konik 2025-05-24 12:18:52 +02:00
parent 21828eea8d
commit 9bec12deec
3 changed files with 27 additions and 0 deletions

View file

@ -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"

View file

@ -0,0 +1 @@
hello_bevy()

View file

@ -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::<RubyRuntime>(|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<AssetServer>) {
commands.spawn(Script::<RubyScript>::new(
assets_server.load("examples/ruby/hello_world.rb"),
));
}