Skip to content

Commit

Permalink
add movie currentSpriteNum prop
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdean authored and igorlira committed Aug 30, 2024
1 parent bfb07bd commit 287f8a0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions vm-rust/src/player/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use net_manager::NetManager;
use lazy_static::lazy_static;
use profiling::{end_profiling, start_profiling};
use scope::ScopeResult;
use script::script_get_prop_opt;
use script_ref::ScriptInstanceRef;
use xtra::multiuser::{MultiuserXtraManager, MULTIUSER_XTRA_MANAGER_OPT};

Expand Down Expand Up @@ -336,6 +337,23 @@ impl DirPlayer {
.map(|label| label.label.clone());
Ok(Datum::String(frame_label.unwrap_or_else(|| "0".to_string())))
},
"currentSpriteNum" => {
let script_instance_ref = self.scopes
.get(self.current_scope_ref())
.and_then(|scope| scope.receiver.clone())
.unwrap();

reserve_player_mut(|player| {
let datum_ref = script_get_prop_opt(player, &script_instance_ref, &"spriteNum".to_owned());
if datum_ref.is_some() {
let datum = player.get_datum(&datum_ref.unwrap());
let sprite_num = datum.int_value()?;
Ok(Datum::Int(sprite_num))
} else {
Ok(Datum::Int(0))
}
})
},
_ => self.movie.get_prop(prop),
}
}
Expand Down

0 comments on commit 287f8a0

Please sign in to comment.