@@ -1221,9 +1221,9 @@ function initGUI() {
12211221 return true ;
12221222 }
12231223
1224- function doReplaceVariable ( varId , newVarName ) {
1224+ function doReplaceVariable ( varId , newVarName , type ) {
12251225 let wksp = getWorkspace ( ) ;
1226- let v = wksp . getVariable ( newVarName ) ;
1226+ let v = wksp . getVariable ( newVarName , type ) ;
12271227 if ( ! v ) {
12281228 alert ( 'That variable does not exist...' ) ;
12291229 return ;
@@ -1233,8 +1233,11 @@ function initGUI() {
12331233 let blocks = getVariableUsesById ( varId ) ;
12341234 for ( const block of blocks ) {
12351235 try {
1236- // block.getInput(0).fieldRow[0].setValue(newVId);
1237- block . getField ( "VARIABLE" ) . setValue ( newVId ) ;
1236+ if ( type === "" ) {
1237+ block . getField ( "VARIABLE" ) . setValue ( newVId ) ;
1238+ } else {
1239+ block . getField ( "LIST" ) . setValue ( newVId ) ;
1240+ }
12381241 } catch ( e ) {
12391242 // ignore
12401243 }
@@ -1501,7 +1504,7 @@ function initGUI() {
15011504 let v = wksp . getVariableById ( selVarID ) ;
15021505 let varName = window . prompt ( `Griffpatch: Switch all '${ v . name } ' in this sprite for the variable named:` ) ;
15031506 if ( varName ) {
1504- doReplaceVariable ( selVarID , varName ) ;
1507+ doReplaceVariable ( selVarID , varName , v . type ) ;
15051508 }
15061509 } , 0 )
15071510 e . preventDefault ( ) ;
@@ -1696,14 +1699,11 @@ function initGUI() {
16961699 ` ) ;
16971700 }
16981701
1699- // Is this a variable?
1700- if ( block && ( block . type === 'data_variable' ||
1701- block . type === 'data_changevariableby' ||
1702- block . type === 'data_setvariableto' ) )
1703- {
1702+ // Is this a variable or a list?
1703+ if ( block && ( block . getCategory ( ) === "data" || block . getCategory ( ) === "data-lists" ) ) {
17041704 blocklyContextMenu . insertAdjacentHTML ( 'beforeend' , `
17051705 <div id="s3devReplaceAllVars" class="goog-menuitem s3dev-mi" role="menuitem" style="user-select: none; border-top: 1px solid hsla(0, 0%, 0%, 0.15);">
1706- <div class="goog-menuitem-content" style="user-select: none;">Swap Variable in Sprite</div>
1706+ <div class="goog-menuitem-content" style="user-select: none;">Swap ${ block . getCategory ( ) === "data" ? " Variable" : "List" } in Sprite</div>
17071707 </div>
17081708 ` ) ;
17091709 selVarID = block . getVars ( ) [ 0 ] ;
0 commit comments