Discuss Scratch

BosenChang
Scratcher
1000+ posts

If (sprite name) showing? block

Duplicate!
There is a topic about show and hide!
KittyFireSt0rm
Scratcher
1000+ posts

If (sprite name) showing? block

BosenChang wrote:

Duplicate!
There is a topic about show and hide!

Actually yours is the duplicate as this one is older than yours
Seth_Zaw
Scratcher
100+ posts

If (sprite name) showing? block

salvation_ wrote:

Morimop wrote:

No Support.

show
set [shown? v] to [1]

hide
set [shown? v] to [0]

if <(shown?) = [1]> then
... :: grey
end
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!
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)
Seth_Zaw
Scratcher
100+ posts

If (sprite name) showing? block

salvation_ wrote:

1132262 wrote:

salvation_ wrote:

1132262 wrote:

salvation_ wrote:

1132262 wrote:

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]
Thanks but that is not what I want. I want a block that asks if the sprite that is running the code is shown.
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.
I meant sprite or clone depending on which it is.
Hmm. Maybe two separate blocks?
Both are useful…
It should look like this
<shown?>
except purple.
To make it purple, put “:: looks” at the end.
garnetluvcookie
Scratcher
1000+ posts

If (sprite name) showing? block

4dsfunk wrote:

Nambaseking01 wrote:

4dsfunk wrote:

HOW 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.
tehenks
Please be constructive with your posts - “tehenks” doesn't add to the discussion.
whiteandblackcat
Scratcher
1000+ posts

If (sprite name) showing? block

PizzaAddict4Life wrote:

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
Firstly, that's a wonderful mockup, although possibly it should be blue?
<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
Scratcher
100+ posts

If (sprite name) showing? block

Support.This is useful for some things.
HTML-Fan
Scratcher
1000+ posts

If (sprite name) showing? block

I don't know if someone already postet that but you can use:
//Sprite 1
//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])
Then you could use
<([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
Scratcher
1000+ posts

If (sprite name) showing? block

HTML-Fan wrote:

I don't know if someone already postet that but you can use:
//Sprite 1
//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])
Then you could use
<([show v] of [Sprite1 v]) = [1]>
or
<([show v] of [Sprite1 v]) :: operators>
if this gets implemented.
yep, i know. Did you read my post?
HTML-Fan
Scratcher
1000+ posts

If (sprite name) showing? block

whiteandblackcat wrote:

Did you read my post?
Oh, sorry, I didn't.
whiteandblackcat
Scratcher
1000+ posts

If (sprite name) showing? block

HTML-Fan wrote:

whiteandblackcat wrote:

Did you read my post?
Oh, sorry, I didn't.
It's ok, I was just explaining how the workaround can be really annoying to use
HTML-Fan
Scratcher
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.
Maximouse
Scratcher
1000+ posts

If (sprite name) showing? block

HTML-Fan wrote:

I personally don't like sprites
So you make projects without sprites?
HTML-Fan
Scratcher
1000+ posts

If (sprite name) showing? block

Maximouse wrote:

HTML-Fan wrote:

I personally don't like sprites
So you make projects without sprites?
I use C++ and if not, then I make pen projects. They require a sprite (which is annoying, here's my idea) but that doesn't really counts. Signature.
salvation_
Scratcher
100+ posts

If (sprite name) showing? block

whiteandblackcat wrote:

PizzaAddict4Life wrote:

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
Firstly, that's a wonderful mockup, although possibly it should be blue?
<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
Thanks, that was what I was imagining. But I couldn't figure out how to make it.
whiteandblackcat
Scratcher
1000+ posts

If (sprite name) showing? block

HTML-Fan wrote:

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.
I use it much more often than that.
whiteandblackcat
Scratcher
1000+ posts

If (sprite name) showing? block

salvation_ wrote:

(snip)
Thanks, that was what I was imagining. But I couldn't figure out how to make it.
Do you mean how to do the workaround?
salvation_
Scratcher
100+ posts

If (sprite name) showing? block

HTML-Fan wrote:

I don't know if someone already postet that but you can use:
//Sprite 1
//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])
Then you could use
<([show v] of [Sprite1 v]) = [1]>
or
<([show v] of [Sprite1 v]) :: operators>
if this gets implemented.
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.
salvation_
Scratcher
100+ posts

If (sprite name) showing? block

whiteandblackcat wrote:

salvation_ wrote:

(snip)
Thanks, that was what I was imagining. But I couldn't figure out how to make it.
Do you mean how to do the workaround?
I mean the block
<shown?::purple >
I don't know how to make it purple.

Last edited by salvation_ (June 28, 2020 23:25:09)

whiteandblackcat
Scratcher
1000+ posts

If (sprite name) showing? block

salvation_ wrote:

snip
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.
Make a variable named “ID” for the sprite with clones, and check the box for 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:
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)

Powered by DjangoBB