Message receiver in a wait until block

Hello!

I’ve tried making a “wait until I receive” custom block in the editor. And have tried numerous different ways to get it to work. I’ve tried ringifying a “when I receive” block into a wait until block but it just didn’t work so I tried using primitives. I used the same code as the “when I receive” block with the primitives. But that didn’t work either. Is there a way to do this?

Here’s basically what the block is:

Custom Blocks script pic 2

Here’s the link to the project Snap! Build Your Own Blocks

If i remember correctly, if you were to enable dev mode in snap!, you can get a (message) block that reports the last message gotten

Custom Blocks script pic
this won’t work on the green flag, but it works on every other message

The green flag was to serve as an example, but thanks for the info!

Hate to be a burden. But how do I make the message block in

image

Work?

I changed my result rendering, so I thought the selector was a list, sorry

update:
removed the message block
Custom Blocks script pic(5)

The (message) block is deprecated, which is why it can only be found in dev mode, so you shouldn’t use it. If you are wanting to wait for a message, then there’s likely a better way to do what you’re trying to do. I would suggest making a global variable that is set to <true> when the action you want to wait for happens.

The (message) block is deprecated

… because it’s prone to failure if two messages arrive at the same time.

(I know you know, but I thought an explanation would be helpful here.)

I love broken blocks!

fixed
Custom Blocks script pic(6)

Would it be something like this?

You don’t need to WAIT 0.05 seconds. Waiting 0 seconds will be sufficient to cause the thread to yield and any wait until blocks to trigger.

Okay thanks, I didn’t know if it would effect the code in anyway.

Sorry again, how do I make that work?

Do I turn message into a list?

(I made a message variable like @ego-lay_atman-bay Had told me.)

Well, it really depends on what you’re actually trying to do and why you’re needing to wait for a message in the first place. If you’re just trying to do this for no reason other than to see if it’s possible, then you’re not really going to get a good solution. But if you’re working on a larger project (like a game) and are needing to wait for a message, then it’s easier to figure out what a good approach is.

Thanks for the feedback, anything helps!

I was more or less just seeing if it was possible to change the “when I receive” hat block into a block. Than again, I was just messing around with the editor to cure boredom and decided to make custom blocks to help me in the future. (Like the current project I’m working on) so I will probably be using this block sometime in the distant(or near) future.