Skip to content

Commit

Permalink
removed "on_test"
Browse files Browse the repository at this point in the history
  • Loading branch information
zwazel committed Oct 13, 2023
1 parent bcdd9e4 commit 745c20b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
4 changes: 0 additions & 4 deletions assets/scripts/multiple_events_rhai.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ fn on_update(name, delta) {
print(`Hello World! From "${name}" in Update: ${delta}`);

world.despawn_recursive(entity);
}

fn on_test(names) {
print(`Hello World! From Test: "${names}"`);
}
26 changes: 1 addition & 25 deletions examples/rhai/multiple_events_rhai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
App::new()
.add_plugins((DefaultPlugins, ScriptingPlugin))
.add_systems(Startup, setup_entities)
.add_systems(Update, (call_init, call_update, call_test_on_all))
.add_systems(Update, (call_init, call_update))
.add_script_host::<RhaiScriptHost<ScriptArgs>>(PostUpdate)
.add_api_provider::<RhaiScriptHost<ScriptArgs>>(Box::new(RhaiBevyAPIProvider))
.add_script_handler::<RhaiScriptHost<ScriptArgs>, 0, 2>(PostUpdate)
Expand Down Expand Up @@ -141,27 +141,3 @@ fn call_init(
}
}
}

fn call_test_on_all(
mut events: PriorityEventWriter<RhaiEvent<ScriptArgs>>,
to_update: Query<(Entity, Option<&Name>)>,
) {
let mut combined_names_of_all_entities = String::new();
for (_, name) in &to_update {
if let Some(name) = name {
combined_names_of_all_entities.push_str(&name.to_string());
}
}

events.send(
RhaiEvent {
hook_name: "on_test".to_owned(),
args: ScriptArgs {
entity_name: Some(combined_names_of_all_entities),
..Default::default()
},
recipients: Recipients::All,
},
2,
);
}

0 comments on commit 745c20b

Please sign in to comment.