parent
eaffce5c6d
commit
7488de076b
13 changed files with 61 additions and 89 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bevy_scriptum"
|
name = "bevy_scriptum"
|
||||||
authors = ["Jaroslaw Konik <konikjar@gmail.com>"]
|
authors = ["Jaroslaw Konik <konikjar@gmail.com>"]
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
@ -15,7 +15,7 @@ lua = ["mlua/luajit"]
|
||||||
rhai = ["dep:rhai"]
|
rhai = ["dep:rhai"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { default-features = false, version = "0.13.0", features = [
|
bevy = { default-features = false, version = "0.14", features = [
|
||||||
"bevy_asset",
|
"bevy_asset",
|
||||||
] }
|
] }
|
||||||
serde = "1.0.162"
|
serde = "1.0.162"
|
||||||
|
|
|
||||||
11
README.md
11
README.md
|
|
@ -163,11 +163,12 @@ The examples live in `examples` directory and their corresponding scripts live i
|
||||||
### Bevy compatibility
|
### Bevy compatibility
|
||||||
|
|
||||||
| bevy version | bevy_scriptum version |
|
| bevy version | bevy_scriptum version |
|
||||||
|--------------|----------------------|
|
|--------------|-----------------------|
|
||||||
| 0.13 | 0.4-0.5 |
|
| 0.14 | 0.6 |
|
||||||
| 0.12 | 0.3 |
|
| 0.13 | 0.4-0.5 |
|
||||||
| 0.11 | 0.2 |
|
| 0.12 | 0.3 |
|
||||||
| 0.10 | 0.1 |
|
| 0.11 | 0.2 |
|
||||||
|
| 0.10 | 0.1 |
|
||||||
|
|
||||||
### Promises - getting return values from scripts
|
### Promises - getting return values from scripts
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ currently being supported with security updates.
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ------- | ------------------ |
|
| ------- | ------------------ |
|
||||||
| 0.5 | :white_check_mark: |
|
| 0.6 | :white_check_mark: |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ Add the following to your `Cargo.toml`:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy_scriptum = { version = "0.5", features = ["lua"] }
|
bevy_scriptum = { version = "0.6", features = ["lua"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
or execute `cargo add bevy_scriptum --features lua` from your project directory.
|
or execute `cargo add bevy_scriptum --features lua` from your project directory.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Add the following to your `Cargo.toml`:
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.13"
|
bevy = "0.13"
|
||||||
bevy_scriptum = { version = "0.5", features = ["lua"] }
|
bevy_scriptum = { version = "0.6", features = ["lua"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
If you need a different version of bevy you need to use a matching bevy_scriptum
|
If you need a different version of bevy you need to use a matching bevy_scriptum
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Add the following to your `Cargo.toml`:
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.13"
|
bevy = "0.13"
|
||||||
bevy_scriptum = { version = "0.5", features = ["rhai"] }
|
bevy_scriptum = { version = "0.6", features = ["rhai"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
If you need a different version of bevy you need to use a matching bevy_scriptum
|
If you need a different version of bevy you need to use a matching bevy_scriptum
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use bevy::{app::AppExit, ecs::event::ManualEventReader, prelude::*};
|
use bevy::{app::AppExit, prelude::*};
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
||||||
|
|
@ -7,18 +7,11 @@ fn main() {
|
||||||
// This is just needed for headless console app, not needed for a regular bevy game
|
// This is just needed for headless console app, not needed for a regular bevy game
|
||||||
// that uses a winit window
|
// that uses a winit window
|
||||||
.set_runner(move |mut app: App| {
|
.set_runner(move |mut app: App| {
|
||||||
let mut app_exit_event_reader = ManualEventReader::<AppExit>::default();
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(app_exit_events) = app.world.get_resource_mut::<Events<AppExit>>() {
|
|
||||||
if app_exit_event_reader
|
|
||||||
.read(&app_exit_events)
|
|
||||||
.last()
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.update();
|
app.update();
|
||||||
|
if let Some(exit) = app.should_exit() {
|
||||||
|
return exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
|
@ -26,7 +19,7 @@ fn main() {
|
||||||
.add_systems(Update, call_lua_on_update_from_rust)
|
.add_systems(Update, call_lua_on_update_from_rust)
|
||||||
.add_scripting::<LuaRuntime>(|runtime| {
|
.add_scripting::<LuaRuntime>(|runtime| {
|
||||||
runtime.add_function(String::from("quit"), |mut exit: EventWriter<AppExit>| {
|
runtime.add_function(String::from("quit"), |mut exit: EventWriter<AppExit>| {
|
||||||
exit.send(AppExit);
|
exit.send(AppExit::Success);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use bevy::{app::AppExit, ecs::event::ManualEventReader, prelude::*};
|
use bevy::{app::AppExit, prelude::*};
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
||||||
|
|
@ -7,18 +7,11 @@ fn main() {
|
||||||
// This is just needed for headless console app, not needed for a regular bevy game
|
// This is just needed for headless console app, not needed for a regular bevy game
|
||||||
// that uses a winit window
|
// that uses a winit window
|
||||||
.set_runner(move |mut app: App| {
|
.set_runner(move |mut app: App| {
|
||||||
let mut app_exit_event_reader = ManualEventReader::<AppExit>::default();
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(app_exit_events) = app.world.get_resource_mut::<Events<AppExit>>() {
|
|
||||||
if app_exit_event_reader
|
|
||||||
.read(&app_exit_events)
|
|
||||||
.last()
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.update();
|
app.update();
|
||||||
|
if let Some(exit) = app.should_exit() {
|
||||||
|
return exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
|
@ -45,6 +38,6 @@ fn print_entity_names_and_quit(query: Query<&Name>, mut exit: EventWriter<AppExi
|
||||||
for e in &query {
|
for e in &query {
|
||||||
println!("{}", e);
|
println!("{}", e);
|
||||||
}
|
}
|
||||||
exit.send(AppExit);
|
exit.send(AppExit::Success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use bevy::{app::AppExit, ecs::event::ManualEventReader, prelude::*};
|
use bevy::{app::AppExit, prelude::*};
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::rhai::prelude::*;
|
use bevy_scriptum::runtimes::rhai::prelude::*;
|
||||||
|
|
||||||
|
|
@ -7,18 +7,11 @@ fn main() {
|
||||||
// This is just needed for headless console app, not needed for a regular bevy game
|
// This is just needed for headless console app, not needed for a regular bevy game
|
||||||
// that uses a winit window
|
// that uses a winit window
|
||||||
.set_runner(move |mut app: App| {
|
.set_runner(move |mut app: App| {
|
||||||
let mut app_exit_event_reader = ManualEventReader::<AppExit>::default();
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(app_exit_events) = app.world.get_resource_mut::<Events<AppExit>>() {
|
|
||||||
if app_exit_event_reader
|
|
||||||
.read(&app_exit_events)
|
|
||||||
.last()
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.update();
|
app.update();
|
||||||
|
if let Some(exit) = app.should_exit() {
|
||||||
|
return exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
|
@ -26,7 +19,7 @@ fn main() {
|
||||||
.add_systems(Update, call_rhai_on_update_from_rust)
|
.add_systems(Update, call_rhai_on_update_from_rust)
|
||||||
.add_scripting::<RhaiRuntime>(|runtime| {
|
.add_scripting::<RhaiRuntime>(|runtime| {
|
||||||
runtime.add_function(String::from("quit"), |mut exit: EventWriter<AppExit>| {
|
runtime.add_function(String::from("quit"), |mut exit: EventWriter<AppExit>| {
|
||||||
exit.send(AppExit);
|
exit.send(AppExit::Success);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use bevy::{app::AppExit, ecs::event::ManualEventReader, prelude::*};
|
use bevy::{app::AppExit, prelude::*};
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::rhai::prelude::*;
|
use bevy_scriptum::runtimes::rhai::prelude::*;
|
||||||
|
|
||||||
|
|
@ -6,19 +6,10 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
// This is just needed for headless console app, not needed for a regular bevy game
|
// This is just needed for headless console app, not needed for a regular bevy game
|
||||||
// that uses a winit window
|
// that uses a winit window
|
||||||
.set_runner(move |mut app: App| {
|
.set_runner(move |mut app: App| loop {
|
||||||
let mut app_exit_event_reader = ManualEventReader::<AppExit>::default();
|
app.update();
|
||||||
loop {
|
if let Some(exit) = app.should_exit() {
|
||||||
if let Some(app_exit_events) = app.world.get_resource_mut::<Events<AppExit>>() {
|
return exit;
|
||||||
if app_exit_event_reader
|
|
||||||
.read(&app_exit_events)
|
|
||||||
.last()
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.update();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
|
@ -45,6 +36,6 @@ fn print_entity_names_and_quit(query: Query<&Name>, mut exit: EventWriter<AppExi
|
||||||
for e in &query {
|
for e in &query {
|
||||||
println!("{}", e);
|
println!("{}", e);
|
||||||
}
|
}
|
||||||
exit.send(AppExit);
|
exit.send(AppExit::Success);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::marker::PhantomData;
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
asset::{io::Reader, Asset, AssetLoader, AsyncReadExt as _, LoadContext},
|
asset::{io::Reader, Asset, AssetLoader, AsyncReadExt as _, LoadContext},
|
||||||
utils::BoxedFuture,
|
utils::ConditionalSendFuture,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A loader for script assets.
|
/// A loader for script assets.
|
||||||
|
|
@ -34,7 +34,7 @@ impl<A: Asset + From<String> + GetExtensions> AssetLoader for ScriptLoader<A> {
|
||||||
reader: &'a mut Reader,
|
reader: &'a mut Reader,
|
||||||
_settings: &'a Self::Settings,
|
_settings: &'a Self::Settings,
|
||||||
_load_context: &'a mut LoadContext,
|
_load_context: &'a mut LoadContext,
|
||||||
) -> BoxedFuture<'a, anyhow::Result<A, anyhow::Error>> {
|
) -> impl ConditionalSendFuture<Output = Result<Self::Asset, Self::Error>> {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
reader.read_to_end(&mut bytes).await?;
|
reader.read_to_end(&mut bytes).await?;
|
||||||
|
|
|
||||||
15
src/lib.rs
15
src/lib.rs
|
|
@ -161,11 +161,12 @@
|
||||||
//! ## Bevy compatibility
|
//! ## Bevy compatibility
|
||||||
//!
|
//!
|
||||||
//! | bevy version | bevy_scriptum version |
|
//! | bevy version | bevy_scriptum version |
|
||||||
//! |--------------|----------------------|
|
//! |--------------|-----------------------|
|
||||||
//! | 0.13 | 0.4-0.5 |
|
//! | 0.14 | 0.6 |
|
||||||
//! | 0.12 | 0.3 |
|
//! | 0.13 | 0.4-0.5 |
|
||||||
//! | 0.11 | 0.2 |
|
//! | 0.12 | 0.3 |
|
||||||
//! | 0.10 | 0.1 |
|
//! | 0.11 | 0.2 |
|
||||||
|
//! | 0.10 | 0.1 |
|
||||||
//!
|
//!
|
||||||
//! ## Promises - getting return values from scripts
|
//! ## Promises - getting return values from scripts
|
||||||
//!
|
//!
|
||||||
|
|
@ -372,7 +373,7 @@ impl BuildScriptingRuntime for App {
|
||||||
/// Adds a scripting runtime. Registers required bevy systems that take
|
/// Adds a scripting runtime. Registers required bevy systems that take
|
||||||
/// care of processing and running the scripts.
|
/// care of processing and running the scripts.
|
||||||
fn add_scripting<R: Runtime>(&mut self, f: impl Fn(ScriptingRuntimeBuilder<R>)) -> &mut Self {
|
fn add_scripting<R: Runtime>(&mut self, f: impl Fn(ScriptingRuntimeBuilder<R>)) -> &mut Self {
|
||||||
self.world
|
self.world_mut()
|
||||||
.resource_mut::<MainScheduleOrder>()
|
.resource_mut::<MainScheduleOrder>()
|
||||||
.insert_after(Update, R::Schedule::default());
|
.insert_after(Update, R::Schedule::default());
|
||||||
|
|
||||||
|
|
@ -395,7 +396,7 @@ impl BuildScriptingRuntime for App {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let runtime = ScriptingRuntimeBuilder::<R>::new(&mut self.world);
|
let runtime = ScriptingRuntimeBuilder::<R>::new(self.world_mut());
|
||||||
|
|
||||||
f(runtime);
|
f(runtime);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@ fn run_script<R: Runtime, Out, Marker>(
|
||||||
path: String,
|
path: String,
|
||||||
system: impl IntoSystem<(), Out, Marker>,
|
system: impl IntoSystem<(), Out, Marker>,
|
||||||
) -> Entity {
|
) -> Entity {
|
||||||
let asset_server = app.world.get_resource_mut::<AssetServer>().unwrap();
|
let asset_server = app.world_mut().get_resource_mut::<AssetServer>().unwrap();
|
||||||
let asset = asset_server.load::<R::ScriptAsset>(path);
|
let asset = asset_server.load::<R::ScriptAsset>(path);
|
||||||
|
|
||||||
let entity_id = app.world.spawn(Script::new(asset)).id();
|
let entity_id = app.world_mut().spawn(Script::new(asset)).id();
|
||||||
app.update(); // let `ScriptData` resources be added to entities
|
app.update(); // let `ScriptData` resources be added to entities
|
||||||
app.world.run_system_once(system);
|
app.world_mut().run_system_once(system);
|
||||||
app.update(); // let callbacks be executed
|
app.update(); // let callbacks be executed
|
||||||
|
|
||||||
entity_id
|
entity_id
|
||||||
|
|
@ -91,7 +91,7 @@ macro_rules! scripting_tests {
|
||||||
my_int: i64,
|
my_int: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
app.world.init_resource::<IntResource>();
|
app.world_mut().init_resource::<IntResource>();
|
||||||
|
|
||||||
app.add_scripting::<$runtime>(|runtime| {
|
app.add_scripting::<$runtime>(|runtime| {
|
||||||
runtime.add_function(
|
runtime.add_function(
|
||||||
|
|
@ -112,7 +112,7 @@ macro_rules! scripting_tests {
|
||||||
call_script_on_update_from_rust::<$runtime>,
|
call_script_on_update_from_rust::<$runtime>,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(app.world.get_resource::<IntResource>().unwrap().my_int, 5);
|
assert_eq!(app.world().get_resource::<IntResource>().unwrap().my_int, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -125,7 +125,7 @@ macro_rules! scripting_tests {
|
||||||
b: String,
|
b: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
app.world.init_resource::<TestResource>();
|
app.world_mut().init_resource::<TestResource>();
|
||||||
|
|
||||||
app.add_scripting::<$runtime>(|runtime| {
|
app.add_scripting::<$runtime>(|runtime| {
|
||||||
runtime.add_function(
|
runtime.add_function(
|
||||||
|
|
@ -147,9 +147,9 @@ macro_rules! scripting_tests {
|
||||||
call_script_on_update_from_rust::<$runtime>,
|
call_script_on_update_from_rust::<$runtime>,
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(app.world.get_resource::<TestResource>().unwrap().a, 5);
|
assert_eq!(app.world().get_resource::<TestResource>().unwrap().a, 5);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.world.get_resource::<TestResource>().unwrap().b,
|
app.world().get_resource::<TestResource>().unwrap().b,
|
||||||
String::from("test")
|
String::from("test")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +176,7 @@ macro_rules! scripting_tests {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
<$runtime>::assert_state_key_value_i32(&app.world, entity_id, "a_value", 1i32);
|
<$runtime>::assert_state_key_value_i32(&app.world(), entity_id, "a_value", 1i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -206,9 +206,9 @@ macro_rules! scripting_tests {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
<$runtime>::assert_state_key_value_i32(&app.world, entity_id, "a_value", 1i32);
|
<$runtime>::assert_state_key_value_i32(&app.world(), entity_id, "a_value", 1i32);
|
||||||
<$runtime>::assert_state_key_value_string(
|
<$runtime>::assert_state_key_value_string(
|
||||||
&app.world,
|
&app.world(),
|
||||||
entity_id,
|
entity_id,
|
||||||
"b_value",
|
"b_value",
|
||||||
&String::from("abc"),
|
&String::from("abc"),
|
||||||
|
|
@ -237,8 +237,8 @@ macro_rules! scripting_tests {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
<$runtime>::assert_state_key_value_i32(&app.world, entity_id, "a_value", 1i32);
|
<$runtime>::assert_state_key_value_i32(&app.world(), entity_id, "a_value", 1i32);
|
||||||
<$runtime>::assert_state_key_value_i32(&app.world, entity_id, "b_value", 2i32);
|
<$runtime>::assert_state_key_value_i32(&app.world(), entity_id, "b_value", 2i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -303,7 +303,7 @@ macro_rules! scripting_tests {
|
||||||
call_script_on_update_from_rust::<$runtime>,
|
call_script_on_update_from_rust::<$runtime>,
|
||||||
);
|
);
|
||||||
|
|
||||||
<$runtime>::assert_state_key_value_i64(&app.world, entity_id, "times_called", 1i64);
|
<$runtime>::assert_state_key_value_i64(&app.world(), entity_id, "times_called", 1i64);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -320,7 +320,7 @@ macro_rules! scripting_tests {
|
||||||
call_script_on_update_from_rust::<$runtime>,
|
call_script_on_update_from_rust::<$runtime>,
|
||||||
);
|
);
|
||||||
|
|
||||||
<$runtime>::assert_state_key_value_i32(&app.world, entity_id, "x", 123i32);
|
<$runtime>::assert_state_key_value_i32(&app.world(), entity_id, "x", 123i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -357,7 +357,7 @@ macro_rules! scripting_tests {
|
||||||
call_script_on_update_from_rust::<$runtime>,
|
call_script_on_update_from_rust::<$runtime>,
|
||||||
);
|
);
|
||||||
|
|
||||||
app.world.run_system_once(|tagged: Query<&MyTag>| {
|
app.world_mut().run_system_once(|tagged: Query<&MyTag>| {
|
||||||
tagged.single();
|
tagged.single();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -371,7 +371,7 @@ macro_rules! scripting_tests {
|
||||||
times_called: u8,
|
times_called: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
app.world.init_resource::<TimesCalled>();
|
app.world_mut().init_resource::<TimesCalled>();
|
||||||
|
|
||||||
app.add_scripting::<$runtime>(|runtime| {
|
app.add_scripting::<$runtime>(|runtime| {
|
||||||
runtime.add_function(String::from("rust_func"), |mut res: ResMut<TimesCalled>| {
|
runtime.add_function(String::from("rust_func"), |mut res: ResMut<TimesCalled>| {
|
||||||
|
|
@ -390,7 +390,7 @@ macro_rules! scripting_tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.world
|
app.world()
|
||||||
.get_resource::<TimesCalled>()
|
.get_resource::<TimesCalled>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.times_called,
|
.times_called,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue