Skip to content
Discussion options

You must be logged in to vote

You can't keep a &mut World alive in your environment for longer than the duration of one exclusive system, because rust rules require you to never, ever have two aliasing (=alive at the same time) mutable references to the same variable.

What you can do is fill the SeekerEnv with an empty dummy World::new() when creating it.
When you want to actually run the wasm script with access to the world, you can do something like this:

fn run_scripts_system(world: &mut World) {
  let seeker_env = ...;
  
  std::mem::swap(world, &mut seeker_env.world);
  // run scripts
  std::mem::swap(&mut seeker_env.world, world);
}

(it can't be exactly this because of the arc and mutex, but the point is to have…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@haike0513
Comment options

Answer selected by alice-i-cecile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
O-Web Specific to web (WASM) builds
3 participants
Converted from issue

This discussion was converted from issue #5132 on June 29, 2022 02:14.