Discuss Scratch

Daxanena
New Scratcher
3 posts

How to make a Sprite reactto the answer to a question another Sprite asks???

Hi guys.
Ca anyone help me with this?
Not sure where my logic is wrong.

I have a Sprite asking a Yes/No question. Everything is fine it's reacting to the answers the way it's supposed to.

The problem is I have another Sprite that I need to react to the same answers.
Not sure if the “answer” variable is set to the Sprite that asks the question or not. Even looked through the events tab thinking I can tie the events together some other way.

I ran out of ideas.
Please help!!!

MrNanners
Scratcher
100+ posts

How to make a Sprite reactto the answer to a question another Sprite asks???

store answers here like this
add (answer) to [list v]
Daxanena
New Scratcher
3 posts

How to make a Sprite reactto the answer to a question another Sprite asks???

Looks like a simple enough solution. Only problem is I haven't started using lists just yet .

I might of miswritten earlier.
The “ Yes/No question” is actually a question that can be answered with any string, the Sprite only reacts (changes costumes, moves etc) if the answer is Yes or No. I need my other Sprite to be able to interact to the same answer.

Is there another way, besides using a list?
drchubbington
Scratcher
100+ posts

How to make a Sprite reactto the answer to a question another Sprite asks???

Looks to me like the answer block is common to all sprites. If you need to store the answer after more questions are asked, you will have to use variables or lists.
I also suggest sharing the project so we can see it for ourselves.

Last edited by drchubbington (Jan. 9, 2022 21:36:57)

Daxanena
New Scratcher
3 posts

How to make a Sprite reactto the answer to a question another Sprite asks???

This is it so far:

https://scratch.mit.edu/projects/625808262

The dog should react to the answers as they are received. I will add more interactions as soon as I figure out how to make it work.
Unfortunately haven't figured that part out.

This version has the “answers” variable, that I tried to give the value of the answer received from the console.
crabraveprogrammer
Scratcher
100+ posts

How to make a Sprite reactto the answer to a question another Sprite asks???

Just use broadcasts to tell the other sprite that the question has been asked.
Dezach
Scratcher
100+ posts

How to make a Sprite reactto the answer to a question another Sprite asks???

To add to crabraveprogrammer's answer

crabraveprogrammer wrote:

Just use broadcasts to tell the other sprite that the question has been asked.

Try something like:

For the sprite “Devin”:
...
ask [Do you want to go for a walk?] and wait
broadcast [Answer v]
...
For the sprite “Puppy”:
when I receive [Answer v]
if <(answer) = [yes]> then
...
end
if <(answer) = [no]> then
...
end

After each question you want to ask in the sprite “Devin” (or any other), add the broadcast block.

Powered by DjangoBB