You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just came across a small issue.
I need to send out PriorityEvents from a rust function that is registered as a script function.
So it has only access to the ScriptWorld.
With the Normal Bevy Events I can just use world.send_event().
But I can't seem to figure out how to send out priority events with only having the ScriptWorld.
Did I miss anything?
The text was updated successfully, but these errors were encountered:
Hi @zwazel thanks!
What do you mean by a rust function registered as a script function, am I correct in thinking you're trying to send out events back from the script to the bevy world?
In this case you can do something similar to world.send_event which is defined using world.send_event_batch like so:
/// Sends a batch of [`Event`]s from an iterator.#[inline]pubfnsend_event_batch<E:Event>(&mutself,events:implIntoIterator<Item = E>){matchself.get_resource_mut::<Events<E>>(){Some(mut events_resource) => events_resource.extend(events),None => bevy_utils::tracing::error!("Unable to send event `{}`\n\tEvent must be added to the app with `add_event()`\n\thttps://docs.rs/bevy/*/bevy/app/struct.App.html#method.add_event ",
std::any::type_name::<E>()),}}
in this case instead of Events you'll simply use PriorityEvents like so:
/// Sends a batch of [`Event`]s from an iterator.#[inline]pubfnsend_event_batch<E:Event>(&mutself,events:implIntoIterator<Item = E>,prio:u32){matchself.get_resource_mut::<PriorityEvents<E>>(){Some(mut events_resource) =>events_resource.events.extend(events.map(|v| EventInstance::new(v, prio))),None => bevy_utils::tracing::error!("Unable to send event `{}`\n\tEvent must be added to the app with `add_event()`\n\thttps://docs.rs/bevy/*/bevy/app/struct.App.html#method.add_event ",
std::any::type_name::<E>()),}}
Hi, love this crate!
I just came across a small issue.
I need to send out PriorityEvents from a rust function that is registered as a script function.
So it has only access to the ScriptWorld.
With the Normal Bevy Events I can just use world.send_event().
But I can't seem to figure out how to send out priority events with only having the ScriptWorld.
Did I miss anything?
The text was updated successfully, but these errors were encountered: