Skip to content

Commit

Permalink
empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
zwazel committed Nov 15, 2023
1 parent d4afc88 commit 478e105
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions examples/rhai/wrappers_rhai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use bevy_mod_scripting_rhai::{
docs::RhaiDocFragment, rhai::Engine, RhaiContext, RhaiEvent, RhaiScriptHost,
};
use bevy_script_api::rhai::{
bevy::RhaiBevyAPIProvider,
std::{RegisterVecType, RhaiCopy},
ReflectRhaiProxyable, RegisterForeignRhaiType,
bevy::RhaiBevyAPIProvider, std::RegisterVecType, RegisterForeignRhaiType,
};

// Step 1. Rust representation
Expand All @@ -25,6 +23,7 @@ pub struct MyThing {
usize: usize,
string: String,
array: Vec<usize>,
empty_array: Vec<usize>,
}

impl MyThing {
Expand All @@ -36,6 +35,7 @@ impl MyThing {
fn init(mut commands: Commands) {
commands.insert_resource(MyThing {
array: vec![1, 2, 3],
empty_array: vec![],
string: "Hello World!".to_owned(),
usize: 42,
});
Expand All @@ -54,6 +54,16 @@ fn run_one_shot(world: &mut World) {
print(`MyThing.usize: ${my_thing.usize}`);
print(`MyThing.array: ${my_thing.array}`);
print(`MyThing.array[0]: ${my_thing.array[0]}`);
print(`Looping through MyThing.array:`);
for array_element in my_thing.array {
print(`MyThing.array element: ${array_element}`);
}
print(`MyThing.empty_array: ${my_thing.empty_array}`);
print(`Looping through MyThing.empty_array:`);
for empty_array_element in my_thing.empty_array {
print(`MyThing.empty_array element: ${empty_array_element}`);
}
print(`MyThing.empty_array[0]: ${my_thing.empty_array[0]}`);
}
"#
.as_bytes(),
Expand Down

0 comments on commit 478e105

Please sign in to comment.