You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 18, 2026. It is now read-only.
In the meshV2 extension, when a broadcast message is received from the mesh network, it might not exist in the local Scratch project. Currently, if the message name is not found in the project's variables, the broadcast is ignored, and the message doesn't appear in the block dropdowns.
Current Behavior
src/extensions/scratch3_mesh_v2/mesh-service.js#broadcastEvent triggers event_broadcast opcode with a message name.
Scratch3EventBlocks.broadcast (in src/blocks/scratch3_event.js) uses lookupBroadcastMsg.
If lookupBroadcastMsg returns null (because the message was never created locally), no hats are started.
The received message is not selectable in "when I receive [message]" or "broadcast [message]" block dropdowns because it doesn't exist in stage.variables.
Expected Behavior
When a broadcast message is received via meshV2, if it doesn't exist locally, it should be created automatically on the stage.
The new message should be selectable in the broadcast block dropdowns.
The event_broadcast opcode should be able to trigger the hats for the newly created message.
Proposed Fix
In MeshV2Service (likely in handleBatchEvent or broadcastEvent), add logic to ensure the broadcast message exists:
Get the stage target: const stage = this.runtime.getTargetForStage();
Check if the message exists: let broadcastVar = stage.lookupBroadcastMsg(null, event.name);
Summary
In the meshV2 extension, when a broadcast message is received from the mesh network, it might not exist in the local Scratch project. Currently, if the message name is not found in the project's variables, the broadcast is ignored, and the message doesn't appear in the block dropdowns.
Current Behavior
src/extensions/scratch3_mesh_v2/mesh-service.js#broadcastEventtriggersevent_broadcastopcode with a message name.Scratch3EventBlocks.broadcast(insrc/blocks/scratch3_event.js) useslookupBroadcastMsg.lookupBroadcastMsgreturns null (because the message was never created locally), no hats are started.stage.variables.Expected Behavior
event_broadcastopcode should be able to trigger the hats for the newly created message.Proposed Fix
In
MeshV2Service(likely inhandleBatchEventorbroadcastEvent), add logic to ensure the broadcast message exists:const stage = this.runtime.getTargetForStage();let broadcastVar = stage.lookupBroadcastMsg(null, event.name);stage.createVariable(null, event.name, Variable.BROADCAST_MESSAGE_TYPE);broadcastVar = stage.lookupBroadcastMsg(null, event.name);this.runtime.requestBlocksUpdate();idfrombroadcastVarin theargspassed toevent_broadcast.Locations to modify
src/extensions/scratch3_mesh_v2/mesh-service.jsReferences
Variable.BROADCAST_MESSAGE_TYPE('broadcast_msg')