1- // https://github.com/scratchfoundation/scratch-blocks /blob/f210e042988b91bcdc2abeca7a2d85e178edadb2 /blocks_vertical/procedures.js#L205
1+ // https://github.com/PenguinMod/PenguinMod-Blocks /blob/a92e9599ad2820ddda8b668a1d254931537be43e /blocks_vertical/procedures.js#L293
22export function modifiedCreateAllInputs ( connectionMap ) {
3+ this . createIcon_ ( )
4+
35 // Split the proc into components, by %n, %b, %s and %l (ignoring escaped).
4- var procComponents = this . procCode_ . split ( / (? = [ ^ \\ ] % [ n b s l ] ) / ) ;
6+ var procComponents = this . procCode_ . split ( / (? = [ ^ \\ ] % [ n b s l c ] ) / ) ;
57 procComponents = procComponents . map ( function ( c ) {
68 return c . trim ( ) ; // Strip whitespace.
79 } ) ;
@@ -10,21 +12,27 @@ export function modifiedCreateAllInputs(connectionMap) {
1012 var argumentCount = 0 ;
1113 for ( var i = 0 , component ; ( component = procComponents [ i ] ) ; i ++ ) {
1214 var labelText ;
15+ var argumentType = component . substring ( 1 , 2 ) ;
16+ var id = this . argumentIds_ [ argumentCount ] ;
1317 // Don't treat %l as an argument
14- if ( component . substring ( 0 , 1 ) == "%" && component . substring ( 1 , 2 ) !== "l" ) {
15- var argumentType = component . substring ( 1 , 2 ) ;
18+ if ( component . substring ( 0 , 1 ) == '%' && ( [ 'n' , 's' , 'b' , 'c' ] . includes ( argumentType ) ) && id ) {
19+ /*
1620 if (!(argumentType == "n" || argumentType == "b" || argumentType == "s")) {
1721 throw new Error("Found an custom procedure with an invalid type: " + argumentType);
1822 }
23+ */
1924 labelText = component . substring ( 2 ) . trim ( ) ;
2025
21- var id = this . argumentIds_ [ argumentCount ] ;
22-
23- var input = this . appendValueInput ( id ) ;
24- if ( argumentType == "b" ) {
25- input . setCheck ( "Boolean" ) ;
26+ if ( argumentType == 'c' ) {
27+ var input = this . appendStatementInput ( id )
28+ } else {
29+ var input = this . appendValueInput ( id ) ;
2630 }
27- this . populateArgument_ ( argumentType , argumentCount , connectionMap , id , input ) ;
31+ if ( argumentType == 'b' ) {
32+ input . setCheck ( 'Boolean' ) ;
33+ }
34+ this . populateArgument_ ( argumentType , argumentCount , connectionMap , id ,
35+ input ) ;
2836 argumentCount ++ ;
2937 } else {
3038 labelText = component == "%l" ? " " : component . replace ( "%l" , "" ) . trim ( ) ;
@@ -36,7 +44,7 @@ export function modifiedCreateAllInputs(connectionMap) {
3644 this . procCode_ = this . procCode_ . replace ( / % l / g, "" ) ;
3745}
3846
39- //https://github.com/scratchfoundation/scratch-blocks /blob/f210e042988b91bcdc2abeca7a2d85e178edadb2 /blocks_vertical/procedures.js#L565
47+ //https://github.com/PenguinMod/PenguinMod-Blocks /blob/a92e9599ad2820ddda8b668a1d254931537be43e /blocks_vertical/procedures.js#L716
4048export function modifiedUpdateDeclarationProcCode ( prefixLabels = false ) {
4149 this . procCode_ = "" ;
4250 this . displayNames_ = [ ] ;
@@ -49,16 +57,22 @@ export function modifiedUpdateDeclarationProcCode(prefixLabels = false) {
4957 if ( input . type == 5 ) {
5058 // replaced Blocky.DUMMY_VALUE with 5
5159 this . procCode_ += ( prefixLabels ? "%l " : "" ) + input . fieldRow [ 0 ] . getValue ( ) ; // modified to prepend %l delimiter, which prevents label merging
52- } else if ( input . type == 1 ) {
53- // replaced Blocky.INPUT_VALUE with 1
60+ } else if ( input . type == 1 || input . type == 3 ) {
61+ // replaced Blocky.INPUT_VALUE with 1 and Blockly.NEXT_STATEMENT with 3
5462 // Inspect the argument editor.
5563 var target = input . connection . targetBlock ( ) ;
56- this . displayNames_ . push ( target . getFieldValue ( " TEXT" ) ) ;
64+ this . displayNames_ . push ( target . getFieldValue ( ' TEXT' ) ) ;
5765 this . argumentIds_ . push ( input . name ) ;
58- if ( target . type == "argument_editor_boolean" ) {
59- this . procCode_ += "%b" ;
60- } else {
61- this . procCode_ += "%s" ;
66+ switch ( target . type ) {
67+ case 'argument_editor_string_number' :
68+ this . procCode_ += '%s' ;
69+ break ;
70+ case 'argument_editor_boolean' :
71+ this . procCode_ += '%b' ;
72+ break ;
73+ case 'argument_editor_command' :
74+ this . procCode_ += "%c" ;
75+ break ;
6276 }
6377 } else {
6478 throw new Error ( "Unexpected input type on a procedure mutator root: " + input . type ) ;
0 commit comments