Discuss Scratch

marioplays2546
Scratcher
16 posts

What Are The Scratch 3.0 Input Specifiers?

I Wannted to Know, What Are The Scratch 3.0 Input Specifiers?
Scratch 2.0 Input Specifiers:
%b
| Boolean slot

|-
| %c
| Color slot

|-
| %d.<''menu''>
| Numeric slot with menu

|-
| %m.<''menu''>
| Read only slot with menu

|-
| %n
| Numeric slot

|-
| %s
| String slot
But, What Are The Scratch 3.0 Input Specifiers?

CST1229
Scratcher
1000+ posts

What Are The Scratch 3.0 Input Specifiers?

Like, internally? They're specified differently in 3.0, being in a separate “args” property instead of being in the block's prototype string, and also makes it even more confusing by, for example, combining string and number inputs into one value and having to add the number input in the palette:
(some comments added by me)
// scratch-blocks/blocks_vertical/motion.js
 
// move () steps
Blockly.Blocks['motion_movesteps'] = {
  /**
   * Block to move steps.
   * @this Blockly.Block
   */
  init: function() {
    this.jsonInit({
      // the block's prototype string
      "message0": Blockly.Msg.MOTION_MOVESTEPS, // 'move %1 steps'
      "args0": [
        // this is basically the equivalent of %n in 2.0
        {
          "type": "input_value",
          "name": "STEPS"
        }
      ],
      "category": Blockly.Categories.motion,
      "extensions": ["colours_motion", "shape_statement"]
    });
  }
};
 
// scratch-gui/src/lib/make-toolbox-xml.js
// (default block palette)
 
`
${ /* also move () steps */ }
<block type="motion_movesteps">
    <value name="STEPS">
        ${ /* this actually defines the fact that this is a number input */ }
        <shadow type="math_number">
            <field name="NUM">10</field>
        </shadow>
    </value>
</block>
`
Extensions are handled a lot differently and are more automatic (as in, you don't have to define it in 3 places and only the extension's js file)
// scratch-vm/src/extensions/scratch3_pen/index.js
{
    // change pen size by ()
    opcode: 'changePenSizeBy',
    blockType: BlockType.COMMAND,
    text: formatMessage({
        id: 'pen.changeSize',
        // in extensions, inputs are defined by [(NAME)]
        // instead of $(number) in built-in blocks
        // so [SIZE] defines that there's an input there
        default: 'change pen size by [SIZE]',
        description: 'change the diameter of the trail left by a sprite'
    }),
    arguments: {
        SIZE: {
            // this defines that this is a number input
            type: ArgumentType.NUMBER,
            defaultValue: 1
        }
    },
    filter: [TargetType.SPRITE]
},

Last edited by CST1229 (March 29, 2022 04:50:59)

marioplays2546
Scratcher
16 posts

What Are The Scratch 3.0 Input Specifiers?

CST1229 wrote:

Like, internally? They're specified differently in 3.0, being in a separate “args” property instead of being in the block's prototype string, and also makes it even more confusing by, for example, combining string and number inputs into one value and having to add the number input in the palette:
(some comments added by me)
// scratch-blocks/blocks_vertical/motion.js
 
// move () steps
Blockly.Blocks['motion_movesteps'] = {
  /**
   * Block to move steps.
   * @this Blockly.Block
   */
  init: function() {
    this.jsonInit({
      // the block's prototype string
      "message0": Blockly.Msg.MOTION_MOVESTEPS, // 'move %1 steps'
      "args0": [
        // this is basically the equivalent of %n in 2.0
        {
          "type": "input_value",
          "name": "STEPS"
        }
      ],
      "category": Blockly.Categories.motion,
      "extensions": ["colours_motion", "shape_statement"]
    });
  }
};
 
// scratch-gui/src/lib/make-toolbox-xml.js
// (default block palette)
 
`
${ /* also move () steps */ }
<block type="motion_movesteps">
    <value name="STEPS">
        ${ /* this actually defines the fact that this is a number input */ }
        <shadow type="math_number">
            <field name="NUM">10</field>
        </shadow>
    </value>
</block>
`
Extensions are handled a lot differently and are more automatic (as in, you don't have to define it in 3 places and only the extension's js file)
// scratch-vm/src/extensions/scratch3_pen/index.js
{
    // change pen size by ()
    opcode: 'changePenSizeBy',
    blockType: BlockType.COMMAND,
    text: formatMessage({
        id: 'pen.changeSize',
        // in extensions, inputs are defined by [(NAME)]
        // instead of $(number) in built-in blocks
        // so [SIZE] defines that there's an input there
        default: 'change pen size by [SIZE]',
        description: 'change the diameter of the trail left by a sprite'
    }),
    arguments: {
        SIZE: {
            // this defines that this is a number input
            type: ArgumentType.NUMBER,
            defaultValue: 1
        }
    },
    filter: [TargetType.SPRITE]
},
yes but, like, how can you put inputs into custom blocks to make “hacked” Blocks?
(Kinda Like My Signature?)

Last edited by marioplays2546 (March 29, 2022 15:34:47)

CST1229
Scratcher
1000+ posts

What Are The Scratch 3.0 Input Specifiers?

marioplays2546 wrote:

yes but, like, how can you put inputs into custom blocks to make “hacked” Blocks?
You cannot make any other inputs in custom blocks other than %s(tring, = number or text), %b(oolean) and %n(umber, from 2.0) (at least in the definition, I think in a custom block itself more are possible, like color inputs), even with JSON hacking. Also, in 3.0 putting stack blocks in inputs other than C inputs is not possible at all.
marioplays2546
Scratcher
16 posts

What Are The Scratch 3.0 Input Specifiers?

CST1229 wrote:

marioplays2546 wrote:

yes but, like, how can you put inputs into custom blocks to make “hacked” Blocks?
You cannot make any other inputs in custom blocks other than %s(tring, = number or text), %b(oolean) and %n(umber, from 2.0) (at least in the definition, I think in a custom block itself more are possible, like color inputs), even with JSON hacking. Also, in 3.0 putting stack blocks in inputs other than C inputs is not possible at all.
Can You Tell Me How To Edit The Cousom Block In the json?
{"targets":[{"isStage":true,"name":"Stage","variables":{"`jEk@4|i[#*?(8x)AV.-my variable":["my variable",0]},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"cd21514d0531fdffb22204e0ec5ed84a","name":"backdrop1","md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg","dataFormat":"svg","rotationCenterX":240,"rotationCenterY":180}],"sounds":[{"assetId":"83a9787d4cb6f3b7632b4ddfebf74367","name":"pop","dataFormat":"wav","format":"","rate":48000,"sampleCount":1123,"md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"}],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":null},{"isStage":false,"name":"Sprite1","variables":{},"lists":{},"broadcasts":{},"blocks":{":*@.{`wMJ0b]_0wXt#:z":{"opcode":"procedures_definition","next":null,"parent":null,"inputs":{"custom_block":[1,"JxV#zQ2qMMGp4302u(#q"]},"fields":{},"shadow":false,"topLevel":true,"x":44,"y":44},"JxV#zQ2qMMGp4302u(#q":{"opcode":"procedures_prototype","next":null,"parent":":*@.{`wMJ0b]_0wXt#:z","inputs":{"~$/P[EOnA)$BJ}a/tSG}":[1,".{xz#~*h_?i-C-7YT:BB"]},"fields":{},"shadow":true,"topLevel":false,"mutation":{"tagName":"mutation","children":[],"proccode":"block name %s","argumentids":"[\"~$/P[EOnA)$BJ}a/tSG}\"]","argumentnames":"[\"lol\"]","argumentdefaults":"[\"\"]","warp":"false"}},"XEVFO?I-kJ0ci{1y@THl":{"opcode":"procedures_call","next":null,"parent":null,"inputs":{"~$/P[EOnA)$BJ}a/tSG}":[1,[10,""]]},"fields":{},"shadow":false,"topLevel":true,"x":199,"y":-553,"mutation":{"tagName":"mutation","children":[],"proccode":"block name %s","argumentids":"[\"~$/P[EOnA)$BJ}a/tSG}\"]","warp":"false"}},".{xz#~*h_?i-C-7YT:BB":{"opcode":"argument_reporter_string_number","next":null,"parent":"JxV#zQ2qMMGp4302u(#q","inputs":{},"fields":{"VALUE":["lol",null]},"shadow":true,"topLevel":false}},"comments":{},"currentCostume":0,"costumes":[{"assetId":"bcf454acf82e4504149f7ffe07081dbc","name":"costume1","bitmapResolution":1,"md5ext":"bcf454acf82e4504149f7ffe07081dbc.svg","dataFormat":"svg","rotationCenterX":48,"rotationCenterY":50},{"assetId":"0fb9be3e8397c983338cb71dc84d0b25","name":"costume2","bitmapResolution":1,"md5ext":"0fb9be3e8397c983338cb71dc84d0b25.svg","dataFormat":"svg","rotationCenterX":46,"rotationCenterY":53}],"sounds":[{"assetId":"83c36d806dc92327b9e7049a565c6bff","name":"Meow","dataFormat":"wav","format":"","rate":48000,"sampleCount":40681,"md5ext":"83c36d806dc92327b9e7049a565c6bff.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":90,"draggable":false,"rotationStyle":"all around"}],"monitors":[],"extensions":[],"meta":{"semver":"3.0.0","vm":"0.2.0-prerelease.20220322143111","agent":"Mozilla/5.0 (X11; CrOS x86_64 14469.58.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.86 Safari/537.36"}}
AtlasOneCoding
Scratcher
27 posts

What Are The Scratch 3.0 Input Specifiers?

Well first you must find the name of the custom block you wish to edit. It would be easier to find it if the string is formatted, so I will do that for you:
{
"targets": [
{
"isStage": true,
"name": "Stage",
"variables": {
"`jEk@4|i[#*?(8x)AV.-my variable": [
"my variable",
0
]
},
"lists": {},
"broadcasts": {},
"blocks": {},
"comments": {},
"currentCostume": 0,
"costumes": [
{
"assetId": "cd21514d0531fdffb22204e0ec5ed84a",
"name": "backdrop1",
"md5ext": "cd21514d0531fdffb22204e0ec5ed84a.svg",
"dataFormat": "svg",
"rotationCenterX": 240,
"rotationCenterY": 180
}
],
"sounds": [
{
"assetId": "83a9787d4cb6f3b7632b4ddfebf74367",
"name": "pop",
"dataFormat": "wav",
"format": "",
"rate": 48000,
"sampleCount": 1123,
"md5ext": "83a9787d4cb6f3b7632b4ddfebf74367.wav"
}
],
"volume": 100,
"layerOrder": 0,
"tempo": 60,
"videoTransparency": 50,
"videoState": "on",
"textToSpeechLanguage": null
},
{
"isStage": false,
"name": "Sprite1",
"variables": {},
"lists": {},
"broadcasts": {},
"blocks": {
":*@.{`wMJ0b]_0wXt#:z": {
"opcode": "procedures_definition",
"next": null,
"parent": null,
"inputs": {
"custom_block": [
1,
"JxV#zQ2qMMGp4302u(#q"
]
},
"fields": {},
"shadow": false,
"topLevel": true,
"x": 44,
"y": 44
},
"JxV#zQ2qMMGp4302u(#q": {
"opcode": "procedures_prototype",
"next": null,
"parent": ":*@.{`wMJ0b]_0wXt#:z",
"inputs": {
"~$/P[EOnA)$BJ}a/tSG}": [
1,
".{xz#~*h_?i-C-7YT:BB"
]
},
"fields": {},
"shadow": true,
"topLevel": false,
"mutation": {
"tagName": "mutation",
"children": ,
"proccode": "block name %s",
"argumentids": "",
"argumentnames": "",
"argumentdefaults": "",
"warp": "false"
}
},
"XEVFO?I-kJ0ci{1y@THl": {
"opcode": "procedures_call",
"next": null,
"parent": null,
"inputs": {
"~$/P[EOnA)$BJ}a/tSG}": [
1,
[
10,
""
]
]
},
"fields": {},
"shadow": false,
"topLevel": true,
"x": 199,
"y": -553,
"mutation": {
"tagName": "mutation",
"children": ,
"proccode": "block name %s",
"argumentids": "",
"warp": "false"
}
},
".{xz#~*h_?i-C-7YT:BB": {
"opcode": "argument_reporter_string_number",
"next": null,
"parent": "JxV#zQ2qMMGp4302u(#q",
"inputs": {},
"fields": {
"VALUE": [
"lol",
null
]
},
"shadow": true,
"topLevel": false
}
},
"comments": {},
"currentCostume": 0,
"costumes": [
{
"assetId": "bcf454acf82e4504149f7ffe07081dbc",
"name": "costume1",
"bitmapResolution": 1,
"md5ext": "bcf454acf82e4504149f7ffe07081dbc.svg",
"dataFormat": "svg",
"rotationCenterX": 48,
"rotationCenterY": 50
},
{
"assetId": "0fb9be3e8397c983338cb71dc84d0b25",
"name": "costume2",
"bitmapResolution": 1,
"md5ext": "0fb9be3e8397c983338cb71dc84d0b25.svg",
"dataFormat": "svg",
"rotationCenterX": 46,
"rotationCenterY": 53
}
],
"sounds": [
{
"assetId": "83c36d806dc92327b9e7049a565c6bff",
"name": "Meow",
"dataFormat": "wav",
"format": "",
"rate": 48000,
"sampleCount": 40681,
"md5ext": "83c36d806dc92327b9e7049a565c6bff.wav"
}
],
"volume": 100,
"layerOrder": 1,
"visible": true,
"x": 0,
"y": 0,
"size": 100,
"direction": 90,
"draggable": false,
"rotationStyle": "all around"
}
],
"monitors": ,
"extensions": ,
"meta": {
"semver": "3.0.0",
"vm": "0.2.0-prerelease.20220322143111",
"agent": "Mozilla/5.0 (X11; CrOS x86_64 14469.58.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.86 Safari/537.36"
}
}
You can see that custom blocks are listed under an entry titled blocks. You can ignore the jumbles of characters, those are base64 strings Scratch uses to identify objects. Under one of the strings is an entry title “mutation”, this defines a custom block. “proccode” defines the name of the function and amount and type of the values it takes. Before you edit the JSON, you must add the parameters you wish to change. After which, download the updated JSON and view the “mutation” entry as mentioned before. It should now look something like this (remember, this is only an example):
"mutation": {
"tagName": "mutation",
"children": [],
"proccode": "block %s %s %s %s",
"argumentids": "[\"Ao2;F9-2+Tb:bTR1ecah\",\"e=Tz;-8)=_2Z[-U5,b~@\",\"wm?dFUt(EX+AzYv=;r4-\",\"IMJvyBo+#L_#bqDuy.].\"]",
"argumentnames": "[\"x\",\"y\",\"value\",\"list\"]",
"argumentdefaults": "[\"\",\"\",\"\",\"\"]",
"warp": "true"
}
Then, change the input specifier (e.g. one of the %s) to your desired input. Also, do you like Chromebooks?
ant3k5
Scratcher
100+ posts

What Are The Scratch 3.0 Input Specifiers?

%b —- Boolean Slot (e.g. <not<>>, <<> and <>>),
%n —- Numeric Slot (e.g. 1e5, -3e-6) and
%s —- String Slot (e.g. “Hello!”, “Bye-bye!”)

But: first you change it to zip,
then you edit the JSON,
last you change it to sb3.

Powered by DjangoBB