How to make and broadcast a variable

I’m verry confused on how to make one.

what do you mean broadcast?

1 Like

i’m not sure what you mean, so here are a couple things.

How to make the broadcast block from Scratch in Wick Editor (it can transfer other things too!!!)

Javascript, to the best of my knowledge, doesn’t have a direct counterpart for the broadcast block from Scratch. You could do something to replicate, though. (x is any one number or text, in quotes. examples being 5 or “yes”. it’s the same for all x’s.)

// in default script
project.message1 = 0;

//broadcaster, any other script
if(condition) {
project.message1 = x;
}

//receiver (specific change), any other script
if(project.message1 === x) {
// PUT WHAT YOU WANT THE CODE TO DO HERE, you can use the value in the variable up here in the code too, if that's what you were trying to do.
project.message1 = 0;
}

//receiver (any change), any other script
if(!project.message1 === 0) {
// PUT WHAT YOU WANT THE CODE TO DO HERE, you can use the value in the variable up here in the code too, if that's what you were trying to do.
project.message1 = 0;
}
How to make a variable

I’m not the greatest at this, I know you can use like:

var (name) = (input here)

or something like that to make a variable, but I mainly use project.(variable name).

project.(name) = (input)

and then you can call it using

if (project.(name) === (value)) {
}

project variables are automatically reachable by any sprite, while vars are locked to a single sprite (don’t quote me on this, i may be wrong).

Hope this helps!

2 Likes

You can also use window.[variable name], and then every other time you call the variable you can just call its name.

1 Like

I want a variable that when it is triggered it will change something in the clip section

Broadcast example11-8-2023_7-59-35.wick|attachment (12.0 KB)
like this?