Scenes and variables

How can I send a variable over from one scene to another. Like that value, and pick it back up when the new scene receives it?

I tried using like variables and stuff but I can’t figure out a way to use the when I receive block because it only has the flag and other broadcast and I cant type it plus if I use the flag I need data to differentiate it from another flag call.

I think the technique for you to use is to send a list of data from one scene to another

The 1st item in your list can be the differentiator for the flag and then the rest of the list values can carry variable information

ok. Is there anyway you could show me. Because it sort of makes sense but also sort of doesn’t.

I’ve never used scenes so got nothing to help you with sorry

You’ll have to wait for a scene expert to come along

ok thanks

Not a scene expert, but I think what cymplecy is trying to say is in Scene 1, you do something like this:


Then, in a different scene, you receive the data by doing something like this:

That is the general idea. Of course, you could make some variable with the same name in the Different Scene and set them using the data list.

I think somebody forgot to turn off my Split! userscript…

It’s easy to accidentally keep it on while taking screenshots, it’s happened to me once

Nah, I actually turn it on whenever I use Snap! now. Anyways, let’s stop this off topic conversation.

Probably the easiest way is for the receiving scene to load the Create Variables library. Then, in the sending scene, make a name-value list like this


and then in the receiving scene you say

here’s an alternate solution to bh’s that automatically sends all of the sprite’s variables and their values, and then tells the sprite in the second scene to recreate them (without needing custom blocks)


(without needing custom blocks)

The party line around here is that you should use the libraries rather than call the EXTENSION block directly, because we promise to try to keep the library behavior uniform as Snap! changes, but we don’t make any promises about the EXTENSION block’s behavior.

Ok thanks this makes much more sense now.

that’s fair, i just find it annoying to have the entire library of blocks in the palette when i’m only going to use, like, 2 of them

The solution I ended on was switch to scene (2) and send hello for example. With data (variable). Then on the other scene I said When I receive hello (data) set hi to data. All names and stuff can change.

CasinoV2 script pic

CasinoV2 script pic (1)

What’s the point of dynamically creating variables at runtime after switching scenes???
Will those variables be accessed only through metaprogramming?
Why not just use vanilla :snap: to set already existing variables?


Precisely

BTW: why “… of …” not allow the direct “myself” option?

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