Discuss Scratch

Daedalusball
Scratcher
7 posts

How do you make a sprite do things based off another sprite?

So, I was wondering how to make a sprite do things based off what another sprite does. Specifically, I need 4 sprites to change their costume when 1 sprite's costume is changed. These 4 sprites are hidden, and when they are cloned with W, A, S, or D, they are shown.
footsocktoe
Scratcher
1000+ posts

How do you make a sprite do things based off another sprite?

Daedalusball wrote:

So, I was wondering how to make a sprite do things based off what another sprite does. Specifically, I need 4 sprites to change their costume when 1 sprite's costume is changed. These 4 sprites are hidden, and when they are cloned with W, A, S, or D, they are shown.

When the controlling sprite changes costume it sends a broadcast message.
broadcast [Change costume now v]
The other four sprites receive it and change their costumes.
when I receive [Change costume now v]
Daedalusball
Scratcher
7 posts

How do you make a sprite do things based off another sprite?

Thanks. And is there any way for a sprite to sense what costume it's already been?
footsocktoe
Scratcher
1000+ posts

How do you make a sprite do things based off another sprite?

Daedalusball wrote:

Thanks. And is there any way for a sprite to sense what costume it's already been?

You mean, not what costume it is now, but what it once was?

You just need to use the computer memory, that's all. Create a variable called LAST COSTUME and update it as needed.
Daedalusball
Scratcher
7 posts

How do you make a sprite do things based off another sprite?

Thanks! This really helped. Project's almost done.
Daedalusball
Scratcher
7 posts

How do you make a sprite do things based off another sprite?

is there any way to make you not be able to switch a sprite's costume if it's already been that costume?
footsocktoe
Scratcher
1000+ posts

How do you make a sprite do things based off another sprite?

Daedalusball wrote:

is there any way to make you not be able to switch a sprite's costume if it's already been that costume?

Yes. One way is to use the use the IF/THEN block.

However, if what you want to do is have a list of costumes and then randomly select them until they have all been used, then using a LIST variable would be the way to go. Put all your costume names in the list. Choose them randomly and then each time you choose one, delete it from the list.
Daedalusball
Scratcher
7 posts

How do you make a sprite do things based off another sprite?

I need someone to be able to choose which costume to change to, but if one was already used, I want to make it unavailable. I tried this:
ask [which costume? a=X, b=Y, c=Z, etc] and wait
if <(answer) = [a b c d or e, depending on what costume]> then
switch costume to [stuff v]
wait (1) secs
change [the corresponding variable v] by (1)
end
if <<(answer) = [whatever letter]> and <(corresponding variable) = [1]>> then
say [something to the effect of no] for (2) secs
ask [the same question as the first one] and wait
end
but even if the costume wasn't picked before, it won't let you pick it.
footsocktoe
Scratcher
1000+ posts

How do you make a sprite do things based off another sprite?

Daedalusball wrote:

I need someone to be able to choose which costume to change to, but if one was already used, I want to make it unavailable. I tried this:
ask [which costume? a=X, b=Y, c=Z, etc] and wait
if <(answer) = [a b c d or e, depending on what costume]> then
switch costume to [stuff v]
wait (1) secs
change [the corresponding variable v] by (1)
end
if <<(answer) = [whatever letter]> and <(corresponding variable) = [1]>> then
say [something to the effect of no] for (2) secs
ask [the same question as the first one] and wait
end
but even if the costume wasn't picked before, it won't let you pick it.

You are misunderstanding the answer block. All it is is the exact thing they type into it. So in your example the only answers that would trigger anything would be…
a b c d or e, depending on what costume
or…
whatever letter

And you are also misusing the ask block since it is also literal. If you ask “the same question as the first one” then that's what will appear on the screen …
The same question as the first one?
jromagnoli
Scratcher
1000+ posts

How do you make a sprite do things based off another sprite?

Just use:
if <([costume# v] of [Sprite1 v]) = [1]> then
...
end
100th post!
TealWashableMarker
Scratcher
1000+ posts

How do you make a sprite do things based off another sprite?

Can you post a link to the project? It might be easier for everyone to help you that way.
Daedalusball
Scratcher
7 posts

How do you make a sprite do things based off another sprite?

glitches listed in the bottom section.Help!
footsocktoe
Scratcher
1000+ posts

How do you make a sprite do things based off another sprite?

Daedalusball wrote:

glitches listed in the bottom section.Help!

Project is not shared.
Daedalusball
Scratcher
7 posts

How do you make a sprite do things based off another sprite?

Sorry, I thought I shared it. It should be there now.
shadowpanther_1
Scratcher
5 posts

How do you make a sprite do things based off another sprite?

how do I get it so that my sprite1 cannot go through sprite2 if sprite2s colour effect has not changed but wheen he colour effect has changed it can?

https://scratch.mit.edu/projects/942388947/editor/

Last edited by shadowpanther_1 (Feb. 25, 2024 11:44:56)

pythonicKI
Scratcher
100+ posts

How do you make a sprite do things based off another sprite?

shadowpanther_1 wrote:

how do I get it so that my sprite1 cannot go through sprite2 if sprite2s colour effect has not changed but wheen he colour effect has changed it can?

https://scratch.mit.edu/projects/942388947/editor/

Please make a new topic! This is a very old one, you can create a new one by going to “help with scripts” and clicking “new topic.”

Powered by DjangoBB