How to pause one sprite.

I want to know how to pause (not stop) one sprite and then unpause it. The sprite I want to pause is in the middle of a script I want to continue when the pause is over.

I tried "pause all" and "stop other scripts in"

Snap! Example of First Class Everything (berkeley.edu)

Sorry, that doesn't exist. PAUSE ALL works by stopping Snap! 's scheduler, not by doing something separately to every sprite.

What about the wait until block ?

image

this will pause the script until the condition was true...

If you don't mind using javascript, and using a kind of a hack, you can use this library Pause all but this script and unpause all. It has a block that you can use to pause other scripts in this sprite, and more.

But I would use this as a last resort, since wait until might be even better. I also use stop other scripts in sprite, then I do something, then broadcast a message to start everything back up without resetting the project.

@theelementguy @ego-lay_atman-bay

Yes, it's possible, but with Javascript, if do you wanna to only pause a sprite, type the next codes:

Only for the sprite you selected:

myObj = this;
world.children[0].stage.threads.processes.filter(thread => thread.blockReceiver() === myObj).map(thread => thread.pause());

Only for a sprite but directly in a process:

myObj = this.blockReceiver();
world.children[0].stage.threads.processes.filter(thread => thread.blockReceiver() === myObj).map(thread => thread.pause());

@bh

Read this, please:

I think he knows. You didn't have to do that.

The OP was asking to pause one sprite, not one script. Pause one script is just WAIT UNTIL. Pausing all the scripts of one sprite and not scripts of other sprites is what can't be done.

And yes, sure, anything can be done in Javascript if you don't mind other people not using your project -- at least I hope people will learn to react that way to the JS warning, rather than just by checking the box without checking (no pun intended) the code.

bh is not happy about the javascript in snap code
and he is not happy about set block

I think jens is more against javascript then bh.

Sigh. Neither of us hates Javascript—it's what we chose to implement Snap! in, after all. But some people come to Snap! and immediately decide they'd rather program in JS, and just put a Snap! wrapper around their JS program. We find that insulting; Snap! itself has plenty of deep ideas built into it, and plenty to learn about computer science—more than you learn by writing a web app and learning about APIs.

What Jens hates in particular is that for some reason the forum is dominated by JS hackers rather than real Snap! users, and of course that's a self-perpetuating situation: it drives Snap!pers away.

I learned at the last History of Programming Languages conference that the actual story about how Javascript was developed is exactly what I'd guessed from the nature of the language: Netscape hired Brendan Eich to embed a Scheme interpreter in their browser, but once he was onboard, they decided that Scheme looks too weird, and so he had to build it with C/C++/Java-like syntax. Thus we have this weird hybrid, with proper lexically scoped first class procedures, but semicolons.

So, you know, if you think that C-like languages are all there are in the world, you might as well use the one that has good semantics! It's a half-decent language, although it would be better if Eich had understood prototyping OOP better.

But none of this is relevant to the issue at hand, which is, I repeat, that the OP wants to pause all and only the scripts of one sprite, not one script, not all but one script. So you JS hackers are solving the wrong problem. Solving the right problem would, indeed, probably require JS to implement it, but y'all aren't doing that.

In my library there's [scratchblocks]pause[other scripts in sprite v]::control[/scratchblocks]PAUSE OTHER SCRIPTS IN SPRITE, if that helps...

Offtopic

Wow, the <ruby> <rt> tags are so cool!!

For some reason Scratchblocks doesn't work for me:
Screen Shot 2022-04-11 at 8.53.03 PM
but okay, if it's in your library, you win the prize. :~)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.