Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Is there a "if *=*" script?
- Adromeda13
- Scratcher
14 posts
Is there a "if *=*" script?
I'm trying to make a game for Christmas and I need to figure out how to do something like “If backdrop=2, show, if else, hide” but I can't find anything like that. Please help! Oh yeah, this is for a chest sprite and I can't have it showing in the beginning.
- mmate
- Scratcher
19 posts
Is there a "if *=*" script?
Create a variable called backdrop.
http://scratch.mit.edu/projects/38306992/
Look at the code and test it!
Good luck for the Christmas game!
if <(backdrop) = [2]> then
show
end
if <not <(backdrop) = [2]>> thenI made a project, where you can test it:
hide
end
http://scratch.mit.edu/projects/38306992/
Look at the code and test it!
Good luck for the Christmas game!
Last edited by mmate (Dec. 8, 2014 20:17:01)
- lcb01
- Scratcher
43 posts
Is there a "if *=*" script?
Another way to do it, which would be easier, would be:
An easier way to do this would be “if backdrop name = ”so-and-so“. Or, just ”if example = “#”. However, I'm still new to making these scratch block things in forums, so I illustrated with the example above.
when gf clicked
forever
if <(backdrop name) = (example)>
show
else
hide
An easier way to do this would be “if backdrop name = ”so-and-so“. Or, just ”if example = “#”. However, I'm still new to making these scratch block things in forums, so I illustrated with the example above.
Last edited by lcb01 (Dec. 8, 2014 20:27:49)
- drmcw
- Scratcher
1000+ posts
Is there a "if *=*" script?
Another way is
when green flag clicked
hide
when backdrop switches to [backdrop 2 v]
show
- Adromeda13
- Scratcher
14 posts
Is there a "if *=*" script?
Thanks guys! I always didn;t know what the green was for!
- Adromeda13
- Scratcher
14 posts
Is there a "if *=*" script?
Oh yeah, I have another quick question:
Is there a way to put. if sprite1 touching sprite2, sprite3 show?
Is there a way to put. if sprite1 touching sprite2, sprite3 show?
- stickfiregames
- Scratcher
1000+ posts
Is there a "if *=*" script?
You have to use a broadcast:
or a variable:
if <touching [sprite2 v]?> then //put this in sprite1
broadcast [show sprite3 v]
end
when I receive [show sprite3 v] // put this in sprite3
show
or a variable:
forever // put this in sprite1
set [touching v] to <touching [sprite2 v]?> // this sets it to true or false
end
forever // put this in sprite3
if <(touching) = [true]> then
show
else
hide
end
- 79brue
- Scratcher
24 posts
Is there a "if *=*" script?
Like
if <(backdrop name) = [2 ]> then
show
else
hide
end
- Adromeda13
- Scratcher
14 posts
Is there a "if *=*" script?
Thanks again, guys! I should be good for now, now.
- Discussion Forums
- » Help with Scripts
- » Is there a "if *=*" script?