Skip to content

Commit

Permalink
add sendAllSprites
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdean authored and igorlira committed Aug 30, 2024
1 parent 287f8a0 commit 4e41244
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions vm-rust/src/player/handlers/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ impl BuiltInHandlerManager {
"call" => true,
"new" => true,
"callAncestor" => true,
"sendAllSprites" => true,
_ => false,
}
}
Expand All @@ -167,6 +168,7 @@ impl BuiltInHandlerManager {
"call" => Self::call(args).await,
"new" => TypeHandlers::new(args).await,
"callAncestor" => TypeHandlers::call_ancestor(args).await,
"sendAllSprites" => MovieHandlers::send_all_sprites(args).await,
_ => {
let msg = format!("No built-in async handler: {}", name);
return Err(ScriptError::new(msg));
Expand Down
11 changes: 10 additions & 1 deletion vm-rust/src/player/handlers/movie.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{director::lingo::datum::Datum, player::{cast_lib::INVALID_CAST_MEMBER_REF, datum_formatting::format_datum, reserve_player_mut, score::get_sprite_at, DatumRef, ScriptError}};
use crate::{director::lingo::datum::Datum, player::{cast_lib::INVALID_CAST_MEMBER_REF, datum_formatting::format_datum, events::player_invoke_global_event, reserve_player_mut, score::get_sprite_at, DatumRef, ScriptError}};

pub struct MovieHandlers {}

Expand Down Expand Up @@ -79,6 +79,15 @@ impl MovieHandlers {
})
}

pub async fn send_all_sprites(args: &Vec<DatumRef>) -> Result<DatumRef, ScriptError> {
let (message, remaining_args) = reserve_player_mut(|player| {
let message = player.get_datum(&args[0]).symbol_value().unwrap();
let remaining_args = &args[1..].to_vec();
(message.clone(), remaining_args.clone())
});
player_invoke_global_event(&message, &remaining_args).await
}

pub fn external_param_value(args: &Vec<DatumRef>) -> Result<DatumRef, ScriptError> {
reserve_player_mut(|player| {
let key = player.get_datum(&args[0]).string_value()?;
Expand Down

0 comments on commit 4e41244

Please sign in to comment.