Why does variadic version need a return block?

I was playing around trying to come up with an alternative solution to

I've got this working

but when I try and make it variadic - I need to add a return block otherwise it errors

Any ideas?

Your (option) input variable is equal to (list ({wait (1) secs switch to costume [Turtle V] wait (1) secs}@>) @<>. Because it is a list, Snap! behaves in a peculiar way (this actually came up in a previous topic as well). Specifically, RUN (and other commands) is, according to jens, not supposed to be hyperized. Thus, one would expect that RUN would just error "Expecting a script but getting a list". However, this is not the case. Instead, run behaves like call: it errors when a script doesn't report anything. To fix, simply run (item (1 v) of (option))@:> instead.

Also, for optional inputs, I would recommend making the variadic input static (found by clicking the cog in the input type menu).

Finally, in the course of my investigation into RUN, it turns out it is even more bugged than I thought:


Moreover, the x position here can vary (once I saw it at 3880).

Thanks - silly me forgetting that a variadic input is returned as a list :slight_smile:

What does setting it to static do?

It means that you can't drop a list on the variadic input, and thus there aren't the three vertical dots either.

Thank you for doing this! I have no idea how you pulled this off.

The basic concept is to split the script into each line and then run them one after another but break out of block using the catch library if the space key is pressed.

It only really works if you hold the key down long enough to exceed the 0.1 second wait which works for your scenario but not in other cases

It's still pretty cool. You should post it if you make a finalized version.

Also btw, (and I'm not criticizing), is it supposed to go back to looping after a second?

Well here is the version with @mark4sisb correction in it

And yes - as its wrapped in a forever loop for testing :slight_smile:

Were is it?

Here is my own modification of your block:


It replaces WAIT blocks with:
untitled script pic (14)
SAY FOR blocks with:
untitled script pic (15)
Etcetera. Thus, the script breaks at the exact moment the condition is true. I also made some minor changes:

  1. Both the c-shape and the variadic input are now static, so reporters can't be dropped on them.
  2. I noticed that the OP struggled with the poor handling of labels in variadic c-shapes. They used an underscore to fix the problem, which becomes hard to see when "and run" is visible. I used "$-" this creates a blank character due to [I won't get into why]. This means that there isn't a random underscore when you aren't using the additional c-slot.

Good work ! ( mark4sisb and cymplecy)

This block doesn't seem to work...

Here's the correction:
untitled script pic (38)

and this script give me an error after the condition turn true (space pressed in this case)

Thank you so much! Can you make it so I can drag it to the snap page? Right now it seems like it's an image, and it goes to the costumes instead.

I'm honestly impressed that people were able to solve this. I definitely couldn't have.

click on the image to upscale it, then drag it into Snap

ok I got one!

https://snap.berkeley.edu/snap/snap.html#present:Username=nathenaelhailu08%40gmail.com&ProjectName=Break%20Animation%20in%20Middle

I've got this one working. I altered on mark's and cymplecy's work to make it. Thank you

Just to do that - the scripts can be simplfied considerably

Then we've got it! Thanks.

Oh yeah, I changed the order of inputs to the wait for/until block and forgot that the other blocks used it. Silly me.

Same problem as in the OP, I forgot that I had closed the project with the fix I had made and started a new one. I am such a doofus. Here are the fixes:

Thank you !

Question: the "and run" script is running only if we exit by the condition but not with the timer ?

Why? For what purpose do these blocks serve to be in this block other than to add blocks to the project the user may probably otherwise not want and add delay to the execution of the block?

Simple. Try running this script and pressing space as you see fit. It will stop the moment you press space, rather than finishing the process of saying whatever it was saying. The same applies to thinking, waiting, and gliding.


@loucheman, this should answer your question too: The "and run" part only runs if the condition is true.