@@ -685,8 +685,11 @@ class Blocks {
685685
686686 // Update block value
687687 if ( ! block . fields [ args . name ] ) return ;
688- if ( args . name === 'VARIABLE' || args . name === 'LIST' ||
689- args . name === 'BROADCAST_OPTION' ) {
688+ if ( args . name === 'VARIABLE' ||
689+ args . name === 'LIST' ||
690+ args . name === 'TABLE' ||
691+ args . name === 'BROADCAST_OPTION'
692+ ) {
690693 // Get variable name using the id in args.value.
691694 const variable = this . runtime . getEditingTarget ( ) . lookupVariableById ( args . value ) ;
692695 if ( variable ) {
@@ -726,7 +729,10 @@ class Blocks {
726729 // block but in the case of monitored reporters that have arguments,
727730 // map the old id to a new id, creating a new monitor block if necessary
728731 if ( block . fields && Object . keys ( block . fields ) . length > 0 &&
729- block . opcode !== 'data_variable' && block . opcode !== 'data_listcontents' ) {
732+ block . opcode !== 'data_variable' &&
733+ block . opcode !== 'data_listcontents' &&
734+ block . opcode !== 'data_tablecontents'
735+ ) {
730736
731737 // This block has an argument which needs to get separated out into
732738 // multiple monitor blocks with ids based on the selected argument
@@ -754,6 +760,8 @@ class Blocks {
754760 isSpriteLocalVariable = ! ( this . runtime . getTargetForStage ( ) . variables [ block . fields . VARIABLE . id ] ) ;
755761 } else if ( block . opcode === 'data_listcontents' ) {
756762 isSpriteLocalVariable = ! ( this . runtime . getTargetForStage ( ) . variables [ block . fields . LIST . id ] ) ;
763+ } else if ( block . opcode === 'data_tablecontents' ) {
764+ isSpriteLocalVariable = ! ( this . runtime . getTargetForStage ( ) . variables [ block . fields . TABLE . id ] ) ;
757765 }
758766
759767 const isSpriteSpecific = isSpriteLocalVariable ||
@@ -772,6 +780,18 @@ class Blocks {
772780 this . runtime . requestHideMonitor ( block . id ) ;
773781 } else if ( ! wasMonitored && block . isMonitored ) {
774782 // Tries to show the monitor for specified block. If it doesn't exist, add the monitor.
783+ let mode ;
784+ switch ( block . opcode ) {
785+ case 'data_tablecontents' :
786+ mode = 'table' ;
787+ break ;
788+ case 'data_listcontents' :
789+ mode = 'list' ;
790+ break ;
791+ default :
792+ mode = 'default' ;
793+ break ;
794+ }
775795 if ( ! this . runtime . requestShowMonitor ( block . id ) ) {
776796 this . runtime . requestAddMonitor ( MonitorRecord ( {
777797 id : block . id ,
@@ -781,7 +801,7 @@ class Blocks {
781801 params : this . _getBlockParams ( block ) ,
782802 // @todo (vm#565) for numerical values with decimals, some countries use comma
783803 value : '' ,
784- mode : block . opcode === 'data_listcontents' ? 'list' : 'default'
804+ mode
785805 } ) ) ;
786806 }
787807 }
@@ -961,28 +981,31 @@ class Blocks {
961981 const blocks = optBlocks ? optBlocks : this . _blocks ;
962982 const allReferences = Object . create ( null ) ;
963983 for ( const blockId in blocks ) {
964- let varOrListField = null ;
984+ let varTypeField = null ;
965985 let varType = null ;
966986 if ( blocks [ blockId ] . fields . VARIABLE ) {
967- varOrListField = blocks [ blockId ] . fields . VARIABLE ;
987+ varTypeField = blocks [ blockId ] . fields . VARIABLE ;
968988 varType = Variable . SCALAR_TYPE ;
969989 } else if ( blocks [ blockId ] . fields . LIST ) {
970- varOrListField = blocks [ blockId ] . fields . LIST ;
990+ varTypeField = blocks [ blockId ] . fields . LIST ;
971991 varType = Variable . LIST_TYPE ;
992+ } else if ( blocks [ blockId ] . fields . TABLE ) {
993+ varTypeField = blocks [ blockId ] . fields . TABLE ;
994+ varType = Variable . TABLE_TYPE ;
972995 } else if ( optIncludeBroadcast && blocks [ blockId ] . fields . BROADCAST_OPTION ) {
973- varOrListField = blocks [ blockId ] . fields . BROADCAST_OPTION ;
996+ varTypeField = blocks [ blockId ] . fields . BROADCAST_OPTION ;
974997 varType = Variable . BROADCAST_MESSAGE_TYPE ;
975998 }
976- if ( varOrListField ) {
977- const currVarId = varOrListField . id ;
999+ if ( varTypeField ) {
1000+ const currVarId = varTypeField . id ;
9781001 if ( allReferences [ currVarId ] ) {
9791002 allReferences [ currVarId ] . push ( {
980- referencingField : varOrListField ,
1003+ referencingField : varTypeField ,
9811004 type : varType
9821005 } ) ;
9831006 } else {
9841007 allReferences [ currVarId ] = [ {
985- referencingField : varOrListField ,
1008+ referencingField : varTypeField ,
9861009 type : varType
9871010 } ] ;
9881011 }
@@ -999,16 +1022,18 @@ class Blocks {
9991022 updateBlocksAfterVarRename ( varId , newName ) {
10001023 const blocks = this . _blocks ;
10011024 for ( const blockId in blocks ) {
1002- let varOrListField = null ;
1025+ let varTypeField = null ;
10031026 if ( blocks [ blockId ] . fields . VARIABLE ) {
1004- varOrListField = blocks [ blockId ] . fields . VARIABLE ;
1027+ varTypeField = blocks [ blockId ] . fields . VARIABLE ;
10051028 } else if ( blocks [ blockId ] . fields . LIST ) {
1006- varOrListField = blocks [ blockId ] . fields . LIST ;
1029+ varTypeField = blocks [ blockId ] . fields . LIST ;
1030+ } else if ( blocks [ blockId ] . fields . TABLE ) {
1031+ varTypeField = blocks [ blockId ] . fields . TABLE ;
10071032 }
1008- if ( varOrListField ) {
1009- const currFieldId = varOrListField . id ;
1033+ if ( varTypeField ) {
1034+ const currFieldId = varTypeField . id ;
10101035 if ( varId === currFieldId ) {
1011- varOrListField . value = newName ;
1036+ varTypeField . value = newName ;
10121037 }
10131038 }
10141039 }
0 commit comments