mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-12 06:20:15 -04:00
add STOP_FOR_TARGET runtime event and respond for ask blocks
Remove questions for targets that are individually stopping and progress the asked question if it is from a stopping target.
This commit is contained in:
parent
4583cb821b
commit
574749bbba
3 changed files with 112 additions and 0 deletions
src/engine
|
@ -377,6 +377,15 @@ class Runtime extends EventEmitter {
|
|||
return 'PROJECT_STOP_ALL';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for target being stopped by a stop for target call.
|
||||
* Used by blocks that need to stop individual targets.
|
||||
* @const {string}
|
||||
*/
|
||||
static get STOP_FOR_TARGET () {
|
||||
return 'STOP_FOR_TARGET';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for visual value report.
|
||||
* @const {string}
|
||||
|
@ -1382,6 +1391,9 @@ class Runtime extends EventEmitter {
|
|||
* @param {Thread=} optThreadException Optional thread to skip.
|
||||
*/
|
||||
stopForTarget (target, optThreadException) {
|
||||
// Emit stop event to allow blocks to clean up any state.
|
||||
this.emit(Runtime.STOP_FOR_TARGET, target, optThreadException);
|
||||
|
||||
// Stop any threads on the target.
|
||||
for (let i = 0; i < this.threads.length; i++) {
|
||||
if (this.threads[i] === optThreadException) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue