Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Need help on Restraunt sim!
- RavenRylee
-
100+ posts
Need help on Restraunt sim!
Ok, so I have the dragging function. But, when I drag my Apple onto my knife, it’s supposed to switch its costume to cut. For some reason, it’s not working! Here’s the script:
Can someone help?
when I receive [ tutorial]
show
go to x: (-189) y: (119)
if <touching [ knife] ?> then
wait (0.5) secs
switch costume to [ cut]
end
Can someone help?
Last edited by RavenRylee (March 28, 2025 21:30:50)
- joe1718
-
64 posts
Need help on Restraunt sim!
Oh I know what happened. You need to put a forever loop outside the if statement.
when I receive [tutorial v]You need the forever loop so that it senses if the apple is cut forever.
show
go to x: (-189) y: (119)
forever
if <touching [knife v] ?> then
wait (0.5) secs
switch costume to [cut v]
end
end
Last edited by joe1718 (March 28, 2025 22:11:28)
- geramihasfood
-
100+ posts
Need help on Restraunt sim!
I think you need to implement a ‘wait until’ block because when the message ‘tutorial’ is received, the sprite only checks for a bit before finishing the message. The ‘wait until’ block would make it so that the sprite waited until the sprite would touch the sprite. Unless I understood it incorrectly, I'd change the code to this: Ok, so I have the dragging function. But, when I drag my Apple onto my knife, it’s supposed to switch its costume to cut. For some reason, it’s not working! Here’s the script:when I receive [ tutorial]
show
go to x: (-189) y: (119)
if <touching [ knife] ?> then
wait (0.5) secs
switch costume to [ cut]
end
Can someone help?
when I receive [tutorial v]
show
go to x: (-189) y: (119)
wait until <touching (knife v) ?>
if <touching (knife v) ?> then
wait (0.5) secs
switch costume to (cut v)
end
I hope this helps you out.
- joe1718
-
64 posts
Need help on Restraunt sim!
But I forgot to mention that you need to separate the forever loop and so on with a green flag clicked. Like this:
when green flag clicked
forever
if <touching [knife v] ?> then
wait (0.5) secs
switch costume to [cut v]
end
end
- joe1718
-
64 posts
Need help on Restraunt sim!
I think that could work tooI think you need to implement a ‘wait until’ block because when the message ‘tutorial’ is received, the sprite only checks for a bit before finishing the message. The ‘wait until’ block would make it so that the sprite waited until the sprite would touch the sprite. Unless I understood it incorrectly, I'd change the code to this: Ok, so I have the dragging function. But, when I drag my Apple onto my knife, it’s supposed to switch its costume to cut. For some reason, it’s not working! Here’s the script:when I receive [ tutorial]
show
go to x: (-189) y: (119)
if <touching [ knife] ?> then
wait (0.5) secs
switch costume to [ cut]
end
Can someone help?when I receive [tutorial v]
show
go to x: (-189) y: (119)
wait until <touching (knife v) ?>
if <touching (knife v) ?> then
wait (0.5) secs
switch costume to (cut v)
end
I hope this helps you out.
- RavenRylee
-
100+ posts
Need help on Restraunt sim!
Idk why, but neither worked? I tried both ways! Here’s the link so you can check it out! I only shared it js so y’all could get in. Also, I’m working on the tut/tutorial so the play button won’t work. I hope this link helps!
https://scratch.mit.edu/projects/1154273095
https://scratch.mit.edu/projects/1154273095
- geramihasfood
-
100+ posts
Need help on Restraunt sim!
It works perfectly fine for me. Idk why, but neither worked? I tried both ways! Here’s the link so you can check it out! I only shared it js so y’all could get in. Also, I’m working on the tut/tutorial so the play button won’t work. I hope this link helps!
https://scratch.mit.edu/projects/1154273095
- RavenRylee
-
100+ posts
Need help on Restraunt sim!
Do you mean in my project or in a project you made to test?
- joe1718
-
64 posts
Need help on Restraunt sim!
I made the project work when I remixed it. You can backpack the scripts included which are in the apple sprite. Tell me when you got it so I can unshare that project.
- RavenRylee
-
100+ posts
Need help on Restraunt sim!
Thanks for the project! I made sure to add you to credits! I’m done!
- Rival8347U
-
100+ posts
Need help on Restraunt sim!
Ok, so I have the dragging function. But, when I drag my Apple onto my knife, it’s supposed to switch its costume to cut. For some reason, it’s not working! Here’s the script:when I receive [ tutorial]
show
go to x: (-189) y: (119)
if <touching [ knife] ?> then
wait (0.5) secs
switch costume to [ cut]
Can someone help?
when I receive [ tutorial]
show
go to x: (-189) y: (119)
forever
if <touching [ knife] ?> then
wait (0.5) secs
switch costume to [ cut]
end
Last edited by Rival8347U (March 29, 2025 05:12:54)
- Discussion Forums
- » Help with Scripts
-
» Need help on Restraunt sim!