Broadcast / Received

Issue #43 resolved
Turgut Guneysu created an issue

Hi John,

It is possible to set a variable to a value and broadcast that variable as a message. It comes in correctly on the http://localhost:6473/mb/getBroadcasts.

However, the event block “when ___ received”, if used with a variable, does not detect the message received event. It only works if a value is typed into the white box.

Also, is it possible to have a reporter block that has the incoming message as a value? Same as in SNAP!

TG

Comments (6)

  1. John Maloney repo owner

    However, the event block “when ___ received”, if used with a variable, does not detect the message received event. It only works if a value is typed into the white box.

    That is the intended behavior. Code that used a variable for the received broadcast could be confusing. Do you have a situation in mind where this would be useful?

    Also, is it possible to have a reporter block that has the incoming message as a value? Same as in SNAP!

    That’s currently not possible.

    An alternate way to implement a general message sending system would be to set a variable to the message, then send a broadcast with a fixed name such as “message available”. You could then have the script that responds to that message read and process the message in the variable.

  2. Turgut Guneysu reporter

    Hi John,

    Thanks for the feedback. I can personally certainly do it ala the suggestion re handling the message content.
    My intention was to maintain the paradigm established in SNAP! .

    For some reason, in my mind, I see Scratch, SNAP!, and microBlocks as evolutionary steps for programming kids. Maybe not in that order, but certainly Scratch → microBlocks or Scratch → SNAP! or microBlocks depending on intent and what MC one wants to program.

    Impossibility of being able to report the incoming message can be worked around, as you described. I will start keeping a list of DIFFERENCES between these environments and hopefully publish it to make the transitions easy.

    I love microBlocks and hope you keep making it better and better.

    TG

  3. John Maloney repo owner

    I also see both Snap! and MicroBlocks as possible next steps after Scratch. MicroBlocks requires a microcontroller, of course.

    I love microBlocks and hope you keep making it better and better.

    Thanks!

  4. John Maloney repo owner

    Update: We’ve added the ability to receive “wildcard” broadcasts as you can do in Snap! To receive such a broadcast, leave the broadcast name empty in the “when _ received” hat block. The script will be started (if it isn’t already running) when any broadcast is sent. The advanced block “last message” can be used to get the last broadcast sent. Here’s an example:

  5. Log in to comment