Discuss Scratch
- BosenChang
-
1000+ posts
If (sprite name) showing? block
Duplicate!
There is a topic about show and hide!
There is a topic about show and hide!
- KittyFireSt0rm
-
1000+ posts
If (sprite name) showing? block
Duplicate!
There is a topic about show and hide!
Actually yours is the duplicate as this one is older than yours
- Seth_Zaw
-
100+ posts
If (sprite name) showing? block
Make it a local variable. That might work. (Note: Local variables are different values for each clone, but global variables are the same for each clone)No Support.However if you have a lot of clones that wouldn't work for all of them. What if some clones are shown and some are not you would need this block!show
set [shown? v] to [1]
hide
set [shown? v] to [0]
if <(shown?) = [1]> then
... :: grey
end
- Seth_Zaw
-
100+ posts
If (sprite name) showing? block
To make it purple, put “:: looks” at the end.It should look like thisHmm. Maybe two separate blocks?I meant sprite or clone depending on which it is.When you drag it out of the block list, it should default to the current sprite. That way, it's easy to get the value for the current sprite, but also others if necessary.Thanks but that is not what I want. I want a block that asks if the sprite that is running the code is shown. I made a mockup for you. :)
To use it, just paste the following code:[img]https://secure.wikimedia.org/wikipedia/tinyurl.com%5C/..%5Cyah5d6gt[/img]
Both are useful…<shown?>except purple.
- garnetluvcookie
-
1000+ posts
If (sprite name) showing? block
Please be constructive with your posts - “tehenks” doesn't add to the discussion.tehenksHOW DID YOU MAKE IT LOOK SO 3.0?!?!
http://scratchblocks.github.io/ (I didn't make it, but I assume this is what 1132262 used)
—
Sorry for the mistake with the duplicate, folks, should've looked more properly.
Anyways, support - even though the workaround is simple and this suggestion is slightly controversial, it would be useful to manipulate clones more easily and check if a sprite is shown easily. Because if you have multiple sprites, it'll get a bit overwhelming to create a variable just to know when a sprite is shown or not.
- whiteandblackcat
-
1000+ posts
If (sprite name) showing? block
Firstly, that's a wonderful mockup, although possibly it should be blue? After a bit of thinking, I have come up for a reason why this could be very useful<sprite [ v] showing? :: looks>Why is this important?
Well, this allows other sprites to detect if another is shown or not.
While yes, you can just do a lot of variables, but with a project with 25 sprites it gets very cluttered.
Edit: Changed stack block to boolean
<sprite [ v] showing? :: sensing>
Secondly, Here's my input:
Often when I'm coding, I set up my project by creating all the sprites I think I'll need and setting them to show and hide at the beginning. Now, I'm a pretty organised coder. I plan a lot of stuff out in notebooks and in onenote, but I still end up deciding to add random features or having to rethink how I'm going to code something.
Imagine you're halfway through a huge project. You've realised you need to tell if a sprite's shown. So you begin to hunt down every single use of the show and hide blocks, and tweaking the variable to match. You're tired and sick of doing it, but you persist.
Further down the line, you're just finishing the project. There are a couple of bugs in it; the scripts that use the show/hide variable are firing inconsistently.
A few hours of debugging later, you find the problem. Maybe you made a typo. Maybe you missed one of the instances of a show/hide block. Maybe you selected the wrong variable in the dropdown. It doesn't really matter.
My point is; while the workaround isn't particularly complicated, it can be really hard to implement. Especially without any sort of “search for blocks” function, it's really hard to implement this sort of workaround when you're halfway through a project.
may or may not be written from experience
- Squashyfishy
-
100+ posts
If (sprite name) showing? block
Support.This is useful for some things.
- HTML-Fan
-
1000+ posts
If (sprite name) showing? block
I don't know if someone already postet that but you can use:
//Sprite 1Then you could use
//show is only for this sprite
when green flag clicked
show
set [show v] to [1]
hide
set [show v] to [0]
//Sprite 2
([show v] of [Sprite1 v])
<([show v] of [Sprite1 v]) = [1]>or
<([show v] of [Sprite1 v]) :: operators>if this gets implemented.
Last edited by HTML-Fan (June 28, 2020 08:39:14)
- whiteandblackcat
-
1000+ posts
If (sprite name) showing? block
yep, i know. Did you read my post? I don't know if someone already postet that but you can use://Sprite 1Then you could use
//show is only for this sprite
when green flag clicked
show
set [show v] to [1]
hide
set [show v] to [0]
//Sprite 2
([show v] of [Sprite1 v])<([show v] of [Sprite1 v]) = [1]>or<([show v] of [Sprite1 v]) :: operators>if this gets implemented.
- HTML-Fan
-
1000+ posts
If (sprite name) showing? block
Oh, sorry, I didn't. Did you read my post?
- whiteandblackcat
-
1000+ posts
If (sprite name) showing? block
It's ok, I was just explaining how the workaround can be really annoying to useOh, sorry, I didn't. Did you read my post?

- HTML-Fan
-
1000+ posts
If (sprite name) showing? block
Okay. It is, but I personally don't like sprites, so that's not too annoying for me.
What are the benefits of this? You would just use it for every 50th sprite, so you can just use a workaround.
What are the benefits of this? You would just use it for every 50th sprite, so you can just use a workaround.
- Maximouse
-
1000+ posts
If (sprite name) showing? block
So you make projects without sprites? I personally don't like sprites
- salvation_
-
100+ posts
If (sprite name) showing? block
Thanks, that was what I was imagining. But I couldn't figure out how to make it.Firstly, that's a wonderful mockup, although possibly it should be blue? After a bit of thinking, I have come up for a reason why this could be very useful<sprite [ v] showing? :: looks>Why is this important?
Well, this allows other sprites to detect if another is shown or not.
While yes, you can just do a lot of variables, but with a project with 25 sprites it gets very cluttered.
Edit: Changed stack block to boolean<sprite [ v] showing? :: sensing>
Secondly, Here's my input:
Often when I'm coding, I set up my project by creating all the sprites I think I'll need and setting them to show and hide at the beginning. Now, I'm a pretty organised coder. I plan a lot of stuff out in notebooks and in onenote, but I still end up deciding to add random features or having to rethink how I'm going to code something.
Imagine you're halfway through a huge project. You've realised you need to tell if a sprite's shown. So you begin to hunt down every single use of the show and hide blocks, and tweaking the variable to match. You're tired and sick of doing it, but you persist.
Further down the line, you're just finishing the project. There are a couple of bugs in it; the scripts that use the show/hide variable are firing inconsistently.
A few hours of debugging later, you find the problem. Maybe you made a typo. Maybe you missed one of the instances of a show/hide block. Maybe you selected the wrong variable in the dropdown. It doesn't really matter.
My point is; while the workaround isn't particularly complicated, it can be really hard to implement. Especially without any sort of “search for blocks” function, it's really hard to implement this sort of workaround when you're halfway through a project.
may or may not be written from experience
- whiteandblackcat
-
1000+ posts
If (sprite name) showing? block
I use it Okay. It is, but I personally don't like sprites, so that's not too annoying for me.much more often than that.
What are the benefits of this? You would just use it for every 50th sprite, so you can just use a workaround.
- whiteandblackcat
-
1000+ posts
If (sprite name) showing? block
Do you mean how to do the workaround? (snip)
Thanks, that was what I was imagining. But I couldn't figure out how to make it.
- salvation_
-
100+ posts
If (sprite name) showing? block
This won't work at all for me I am trying to distinguish among sprites and I don't know if someone already postet that but you can use:clones whether the sprite or clone who is running the code is shown.//Sprite 1Then you could use
//show is only for this sprite
when green flag clicked
show
set [show v] to [1]
hide
set [show v] to [0]
//Sprite 2
([show v] of [Sprite1 v])<([show v] of [Sprite1 v]) = [1]>or<([show v] of [Sprite1 v]) :: operators>if this gets implemented.
- salvation_
-
100+ posts
If (sprite name) showing? block
I mean the blockDo you mean how to do the workaround? (snip)
Thanks, that was what I was imagining. But I couldn't figure out how to make it.
<shown?::purple >I don't know how to make it purple.
Last edited by salvation_ (June 28, 2020 23:25:09)
- whiteandblackcat
-
1000+ posts
If (sprite name) showing? block
Make a variable named “ID” for the sprite with clones, and check the box for snip this sprite only. Each clone will have a copy. Now, each time the main sprite clones itself, it needs to change “ID” by one, so each clone has a unique ID. Finally, you need a list, for instance “showhide”. Each clone will modify one slot of the list to keep track of whether it's shown or hidden:
This won't work at all for me I am trying to distinguish among sprites and clones whether the sprite or clone who is running the code is shown.
When flag clicked //This gives each clone a unique ID
repeat (5)
change [cloneID v] by (1) //Make sure this variable is for "This Sprite Only". It won't work if the "all sprites" box is checked.
create clone of [myself v]
end
When I start as a clone //use the list to keep track of whether each clone is shown or hidden.
replace item (cloneID) of [showhide v] with [1] //This list needs to be "For all sprites".
show
replace item (cloneID) of [showhide v] with [0]
hide
<(item (1) of [showhide v]) = [0]> // use this instead of <hidden?>
<(item (1) of [showhide v]) = [0]> //and this instead of <shown?>
//make sure to enter the clone's ID rather than just "1"
Last edited by whiteandblackcat (June 28, 2020 23:36:49)