File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -35,22 +35,22 @@ export default function (Blockly) {
3535
3636 Blockly . Ruby . event_whenbroadcastreceived = function ( block ) {
3737 Blockly . Ruby . targetEventBlock = block ;
38- const message = block . getFieldValue ( 'BROADCAST_OPTION' ) || null ;
39- return `${ Blockly . Ruby . spriteName ( ) } .when(receive:, " ${ message } " ) do\n` ;
38+ const message = Blockly . Ruby . broadcastMessageName ( block . getFieldValue ( 'BROADCAST_OPTION' ) ) ;
39+ return `${ Blockly . Ruby . spriteName ( ) } .when(receive:, ${ message } ) do\n` ;
4040 } ;
4141
4242 Blockly . Ruby . event_broadcast = function ( block ) {
4343 const message = Blockly . Ruby . valueToCode ( block , 'BROADCAST_INPUT' , Blockly . Ruby . ORDER_NONE ) || null ;
44- return `broadcast(" ${ message } " )\n` ;
44+ return `broadcast(${ message } )\n` ;
4545 } ;
4646
4747 Blockly . Ruby . event_broadcastandwait = function ( block ) {
4848 const message = Blockly . Ruby . valueToCode ( block , 'BROADCAST_INPUT' , Blockly . Ruby . ORDER_NONE ) || null ;
49- return `broadcast_and_wait(" ${ message } " )\n` ;
49+ return `broadcast_and_wait(${ message } )\n` ;
5050 } ;
5151
5252 Blockly . Ruby . event_broadcast_menu = function ( block ) {
53- const message = block . getFieldValue ( 'BROADCAST_OPTION' ) || null ;
53+ const message = Blockly . Ruby . broadcastMessageName ( block . getFieldValue ( 'BROADCAST_OPTION' ) ) ;
5454 return [ message , Blockly . Ruby . ORDER_ATOMIC ] ;
5555 } ;
5656
Original file line number Diff line number Diff line change @@ -322,6 +322,17 @@ export default function (Blockly) {
322322 return this . editingTarget . sprite . name ;
323323 } ;
324324
325+ Blockly . Ruby . broadcastMessageName = function ( name ) {
326+ const bm = this . editingTarget . lookupBroadcastMsg ( name ) ;
327+ let message = null ;
328+ if ( bm ) {
329+ return Blockly . Ruby . quote_ ( bm . name ) ;
330+ }
331+ else {
332+ return null ;
333+ }
334+ } ;
335+
325336 Blockly . Ruby . workspaceToCode_ = Blockly . Ruby . workspaceToCode ;
326337
327338 Blockly . Ruby . workspaceToCode = function ( block , target ) {
You can’t perform that action at this time.
0 commit comments