Custom hat block

it would be cool if there was a custom hat block
example
scratchblocks (51)

custom hat blocks should be in here:
image

There is!

untitled script pic

Oh, but it would be cool if there was coloring and stuffs

reasons by YOU why the when <> block is not enough
also,

Oh, Brian, the custom hat block is don't a "forever if" loop with a hat!!! :man_facepalming:t2:
The custom hat block, for me, runs one time until is finished and finally
until when is false until when is true to run again.
Like the "Green Flag" Hat Block, press the green flag button, and if the hat block don't have more scripts to run, the script with the hat block, stop until press the button again.

Yeah, there should be. As you say, @sathvikrias, the when block isn't enough, and there is unintentional support from bh. What is so hard about it anyway?
Why are you substituting the when block when you could easily make a custom hat block option?

The custom hat block option is impossible. :frowning_face:

What's so hard about coding it into Snap!, developers?

No, I'm not a developer of Snap!, I'm a Snap! major user. :frowning_face:

No, not you as a developer, what's so hard for the developers (@bh, @jens) to code it?

Oh, I don't know. :frowning_face:

they weren't intending for you to reply to that.

I don't think you guys have thought this through.

Sure, it'd be easy to add a hat-block-shape option to the initial make-a-block dialog. But then what? You're in the Block Editor; what would be the body of your block?

Because, you see, an ordinary hat block isn't an action block; it doesn't have any code to run. Instead, when some event happens, such as you clicking the green flag, it's the code (inside Snap!) that processes that mouse click that does the work of looking through all the scripts to find the ones headed with when-green-flag-clicked and start them running. The hat block itself does nothing.

You're quite right that the generic WHEN block is different from the others. It does have an action associated with it, namely, checking whether your condition is satisfied. But, don't you see, the same would be true of a custom hat block you make! The example at the top of this thread was
scratchblocks (51)
To make that block work like other non-generic hat blocks, it wouldn't be good enough to make the block itself; you'd have to modify the implementation of the SET block to look for hat blocks checking whatever variable it just changed.

I hope all that's clear and understandable...

and folks, if you want to make a custom hat block that only triggers whenever a condition changes, you should instead make such a condition that only evaluates "true" if the condition changes to what it was before. This, btw, is the exact use case for block variables.

AFAIK that doesn't work if you use the block in another custom block - unless this behaviour has changed, every instance of the custom block shares the definition and therefore the same instance of the block with block variables.

If this is the actual intended use case for block variables, then IMHO the behaviour I described is very inconsistent and should be fixed.

No. Every physical (so to speak) copy of the block has its own block variables, It's only when you call the same copy again that you see block-variable behavior.

Yes, a shared instance of a block also shares its block variables. What are we discussing now?

@danidanijr asks for custom hat blocks that triggers on comparing two values. @bh shows them how Snap's generic When-hat lets you do exactly what this thread has been asking for. Then @alessandrito123 objects because he wants to make it so the hat block only triggers when a value changes. So I show y'all how you can accomplish exactly that toggling When-hat behavior using a block variable. Then @rdococ complains that function definitions are shared by all instances of a block, calling that "behavior very inconsistent" and demanding it "should be fixed". Is this thread still about a feature request for custom hat blocks? Has this thread's request been answered under all possible aspects yet?

Ok "Snapers!", I have already created the block "has [] been changed?", soon I will post a project with many experienced blocks in :snap: or in a Javascript primitive code and
I will explain how it works, with examples. :wink:
¿el valor del bloque  fue cambiado?
Although my block is in Spanish, in the Simple English language it means:
"the value of the block [] is changed?"

Note: The code of the block is same to my major friend "@jens"'s block. :grinning:

Do you mean "the value of the expression ," e.g. "the value of the expression (x)-(y)," or maybe "the value of the variable "? Blocks themselves don't have values.

Let's say I have a "has [value] changed?" boolean block with block variables. I create a new block - let's say it's something like "have any of my attributes changed?" - using it.

If I use multiple instances "have any of my attributes changed?" in two different scripts, each instance shares their copy of the "has [value] changed?" block. Only one of the two scripts will actually notice the change, and which one depends on the script execution order.

I'm sorry if I came off as demanding, but this doesn't seem like consistent behaviour to me. Is there a deeper reason for it?