Save and restore state blocks

When I was exploring BYOB 3.0’s tools, you find the SAVE STATE and RESTORE STATE blocks. While most of the blocks made it into iteration/composition, list utilities, and the sentences and words library, the SAVE AND RESTORE STATE blocks never made it anywhere surprisingly, even though they seem really useful. I have brought them to life in Snap! 11!
Project link:

This is an interesting generalization, but it lacks one property of the old version: making sure not to draw a line while restoring the sprite’s position, while still restoring its pendownness later.

Thanks for the feedback! Changed.

Updated, supports MY COSTUMES and SOUNDS.

And also is binded to the context that created the save.

random thought, I’m not sure why at all, but I expected it to be save ((state)) :: operators as an upvar. functionality-wise, everything works great! I’m not entirely sure why you would need the ON LOAD part anywhere (since you can just do restore state ( state V ) ::operators ... ) but I do agree that this should be integrated in normal snap.

Okay, write the help texts and I’ll make a library.

P.S. I think that if the save block is given no inputs, it should save a small default set of things: position, direction, pen mode, pen color, pen size. The things that are important for turtle graphics, which was the original purpose of these blocks.

I thought that too, but didn’t know what to put. Thanks!

I have maken them library ready:
Save and restore state script pic (1)

maybe use a reporter input instead of anyUE? I would also move the block to sensing or motion.

I found a bug:

It’s there because you can also type variable names.

Fixed!

my issue is that this doesn’t work:


(I just noticed, could you change the block’s first input to not be static? I’m not sure it needs to be :⋅) )

Why

If you’re talking about this:

it’s problematic because that’s the way to usually save blocks for later, but it doesn’t work here.
If you’re talking about

it’s so that you can drop a list of attributes as a list.

In what use case do you need to do either of those things?

any time you want to modify the list of attributes that you save

I see, I will make it allow implicit parameters and explicit rings.