Discuss Scratch

GamesAlt34
Scratcher
82 posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

So it says (even when I type the right answer), “That's not what I ordered.” This is my script:

when I receive [Cashier v]
repeat until <key [m v] pressed?>
wait (pick random (1) to (20)) secs
broadcast [Cashier_Name_Change v]
add (join [Hello, I would like a] (Cashier_Name)) to [game v]
ask [What did they order?] and wait
if <(answer) = (Pizzaanswer)> then
add [Thank you!] to [game v]


else
add [That's not what I ordered.] to [game v]
end
end

And here is the script to the random pizza name:

when I receive [Cashier_Name_Change v]
set [cashier_name v] to (pick random (1) to (4))
if <(cashier_name) = [1]> then
set [cashier_name v] to [Cheese Pizza, please.]
broadcast [answerpizzalol v]
end
if <(cashier_name) = [2]> then
set [cashier_name v] to [Pepperoni Pizza, please.]
broadcast [answerpizzapeperlol v]
end
if <(cashier_name) = [3]> then
set [cashier_name v] to [Sausage Pizza, please.]
broadcast [answersaucelol v]
end
if <(cashier_name) = [4]> then
set [cashier_name v] to [Soda, please.]
broadcast [sodapoplol v]
end

And then these are the answer scripts:
when I receive [answerpizzalol v]
set [pizzaanswer v] to [cheese pizza]
when I receive [answerpizzapeperlol v]
set [pizzaanswer v] to [pepperoni pizza]
when I receive [answersaucelol v]
set [pizzaanswer v] to [sausage pizza]
when I receive [sodapoplol v]
set [pizzaanswer v] to [soda]

Please, can anyone fix this for me?
medians
Scratcher
1000+ posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

Can you send the link to the project?
DexFire
Scratcher
100+ posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

GamesAlt34 wrote:

So it says (even when I type the right answer), “That's not what I ordered.” This is my script:

Please, can anyone fix this for me?
In your first script you have “Pizaaanswer” and the last four “pizzaanswer”. Are you sure these are the same variable? I'm assuming it was just a typo when you were making the post, but just check anyways.

Other than that, strings are case sensitive and require exact values. Try copying and pasting the values in those "set pizzaanswer to " blocks into the answer prompt box. You may have a random space or capitalization that is causing you to not get the answer and pizzaanswer to match.
medians
Scratcher
1000+ posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

DexFire wrote:

GamesAlt34 wrote:

So it says (even when I type the right answer), “That's not what I ordered.” This is my script:

Please, can anyone fix this for me?
In your first script you have “Pizaaanswer” and the last four “pizzaanswer”. Are you sure these are the same variable? I'm assuming it was just a typo when you were making the post, but just check anyways.

Other than that, strings are case sensitive and require exact values. Try copying and pasting the values in those "set pizzaanswer to " blocks into the answer prompt box. You may have a random space or capitalization that is causing you to not get the answer and pizzaanswer to match.
Though, the equals block is case insensitive. Try it:
10data10
Scratcher
100+ posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

It would be interesting to see the actual project because there might be a order of execution problem where what is added to the “game” list — before the ask block — is out of sync with the value of “pizzaanswer” that is used after the ask block. It might help to change to using broadcast and wait.

GamesAlt34
Scratcher
82 posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

DexFire wrote:

GamesAlt34 wrote:

So it says (even when I type the right answer), “That's not what I ordered.” This is my script:

Please, can anyone fix this for me?
In your first script you have “Pizaaanswer” and the last four “pizzaanswer”. Are you sure these are the same variable? I'm assuming it was just a typo when you were making the post, but just check anyways.

Other than that, strings are case sensitive and require exact values. Try copying and pasting the values in those "set pizzaanswer to " blocks into the answer prompt box. You may have a random space or capitalization that is causing you to not get the answer and pizzaanswer to match.

Yes, they are the same. That was a mistake.
GamesAlt34
Scratcher
82 posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

10data10 wrote:

It would be interesting to see the actual project because there might be a order of execution problem where what is added to the “game” list — before the ask block — is out of sync with the value of “pizzaanswer” that is used after the ask block. It might help to change to using broadcast and wait.

Here!: https://scratch.mit.edu/projects/846866948/
10data10
Scratcher
100+ posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

That was the problem. I changed all of the cashier related broadcasts to “broadcast and wait” and the game list item now matches the pizzaanswer after the question is asked.
GamesAlt34
Scratcher
82 posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

10data10 wrote:

That was the problem. I changed all of the cashier related broadcasts to “broadcast and wait” and the game list item now matches the pizzaanswer after the question is asked.
Thanks! Can you show me it?
medians
Scratcher
1000+ posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

GamesAlt34 wrote:

10data10 wrote:

That was the problem. I changed all of the cashier related broadcasts to “broadcast and wait” and the game list item now matches the pizzaanswer after the question is asked.
Thanks! Can you show me it?
Just change this:
broadcast [ v]
To this:
broadcast [ v] and wait
10data10
Scratcher
100+ posts

Hello, I am trying to make a pizza game were someones asks what to order. But it does not work!

GamesAlt34 wrote:

Thanks! Can you show me it?

Here’s my remix. https://scratch.mit.edu/projects/846985695/


Powered by DjangoBB