diff --git a/content/news/2023-10-21-bevy-0.12/index.md b/content/news/2023-10-21-bevy-0.12/index.md index 22a3f25d61..0c24052cd7 100644 --- a/content/news/2023-10-21-bevy-0.12/index.md +++ b/content/news/2023-10-21-bevy-0.12/index.md @@ -37,11 +37,12 @@ fn increment(mut counter: ResMut) { println!("{}", counter.0); } -let mut world = World::new(); -world.init_resource::(); -let id = world.register_system(increment); -let _ = world.run_system(id); // prints 1 -let _ = world.run_system(id); // prints 2 +fn foo(world: &mut World) { + world.init_resource::(); + let id = world.register_system(increment); + let _ = world.run_system(id); // prints 1 + let _ = world.run_system(id); // prints 2 +} ``` There are three simple steps to using one-shot systems: register a system, store its `SystemId`, and then use either exclusive world access or commands to run the corresponding system.