Scratch_agent_V1 / blocks /boolean_blocks.json
WebashalarForML's picture
Upload 197 files
3abfe5a verified
{
"block_category": "Boolean Blocks",
"description": "Boolean blocks are hexagonal in shape. They represent conditions that evaluate to either 'true' or 'false' and are typically used as inputs for control flow blocks.",
"blocks": [
{
"block_name": "<() < ()>",
"block_type": "operator",
"op_code": "operator_lt",
"block_shape": "Boolean Block",
"functionality": "Checks if the first value is less than the second.",
"inputs": [
{"name": "OPERAND1", "type": "any"},
{"name": "OPERAND2", "type": "any"}
],
"example_standalone": "<(score) < (10)>",
"example_with_other_blocks": [
{
"script": "if <(score) < (10)> then\n say [Keep trying!]",
"explanation": "This script causes the sprite to say 'Keep trying!' if the 'score' variable is less than 10."
}
]
},
{
"block_name": "<() = ()>",
"block_type": "operator",
"op_code": "operator_equals",
"block_shape": "Boolean Block",
"functionality": "Checks if two values are equal.",
"inputs": [
{"name": "OPERAND1", "type": "any"},
{"name": "OPERAND2", "type": "any"}
],
"example_standalone": "<(answer) = (5)>",
"example_with_other_blocks": [
{
"script": "if <(answer) = (5)> then\n say [Correct!]",
"explanation": "This script makes the sprite say 'Correct!' if the value of the 'answer' variable is exactly 5."
}
]
},
{
"block_name": "<() > ()>",
"block_type": "operator",
"op_code": "operator_gt",
"block_shape": "Boolean Block",
"functionality": "Checks if the first value is greater than the second.",
"inputs": [
{"name": "OPERAND1", "type": "any"},
{"name": "OPERAND2", "type": "any"}
],
"example_standalone": "<(health) > (0)>",
"example_with_other_blocks": [
{
"script": "if <(health) > (0)> then\n move (10) steps\nelse\n stop [all v]\nend",
"explanation": "This script moves the sprite if its 'health' is greater than 0; otherwise, it stops all scripts."
}
]
},
{
"block_name": "<<> and <>>",
"block_type": "operator",
"op_code": "operator_and",
"block_shape": "Boolean Block",
"functionality": "Returns 'true' if both provided Boolean conditions are 'true'.",
"inputs": [
{"name": "OPERAND1", "type": "boolean"},
{"name": "OPERAND2", "type": "boolean"}
],
"example_standalone": "<<mouse down?> and <touching [mouse-pointer]?> >",
"example_with_other_blocks": [
{
"script": "if <<mouse down?> and <touching [mouse-pointer]?> > then\n say [You're clicking me!]\nend",
"explanation": "This script makes the sprite say 'You're clicking me!' only if the mouse button is pressed AND the mouse pointer is touching the sprite."
}
]
},
{
"block_name": "<<> or <>>",
"block_type": "operator",
"op_code": "operator_or",
"block_shape": "Boolean Block",
"functionality": "Returns 'true' if at least one of the provided Boolean conditions is 'true'.",
"inputs": [
{"name": "OPERAND1", "type": "boolean"},
{"name": "OPERAND2", "type": "boolean"}
],
"example_standalone": "<<key [left arrow v] pressed?> or <key [a v] pressed?>>",
"example_with_other_blocks": [
{
"script": "if <<key [left arrow v] pressed?> or <key [a v] pressed?>> then\n change x by (-10)\nend",
"explanation": "This script moves the sprite left if either the left arrow key OR the 'a' key is pressed."
}
]
},
{
"block_name": "<not <>>",
"block_type": "operator",
"op_code": "operator_not",
"block_shape": "Boolean Block",
"functionality": "Returns 'true' if the provided Boolean condition is 'false', and 'false' if it is 'true'.",
"inputs": [
{"name": "OPERAND", "type": "boolean"}
],
"example_standalone": "<not <mouse down?>>",
"example_with_other_blocks": [
{
"script": "if <not <touching [Sprite2 v]?>> then\n say [I'm safe!]\nend",
"explanation": "This script makes the sprite say 'I'm safe!' if it is NOT touching 'Sprite2'."
}
]
},
{
"block_name": "<() contains ()?>",
"block_type": "operator",
"op_code": "operator_contains",
"block_shape": "Boolean Block",
"functionality": "Checks if one string contains another string.",
"inputs": [
{"name": "STRING1", "type": "string"},
{"name": "STRING2", "type": "string"}
],
"example_standalone": "<[apple] contains [a]?>",
"example_with_other_blocks": [
{
"script": "if <[answer] contains [yes]?> then\n say [Great!]\nend",
"explanation": "This script makes the sprite say 'Great!' if the 'answer' variable contains the substring 'yes'."
}
]
},
{
"block_name": "<touching ()?>",
"block_type": "Sensing",
"op_code": "sensing_touchingobject",
"block_shape": "Boolean Block",
"functionality": "Checks if its sprite is touching the mouse-pointer, edge, or another specified sprite.",
"inputs": [
{"name": "TOUCHINGOBJECTMENU", "type": "dropdown", "options": ["mouse-pointer", "edge", "Sprite1", "..." ]}
],
"example_standalone": "<touching [edge v]?>",
"example_with_other_blocks": [
{
"script": "if <touching [edge v]?> then\n bounce off edge\nend",
"explanation": "This script makes the sprite reverse direction if it comes into contact with the edge of the stage."
}
]
},
{
"block_name": "<touching color ()?>",
"block_type": "Sensing",
"op_code": "sensing_touchingcolor",
"block_shape": "Boolean Block",
"functionality": "Checks whether its sprite is touching a specified color.",
"inputs": [
{"name": "COLOR", "type": "color"}
],
"example_standalone": "<touching color [#FF0000]?>",
"example_with_other_blocks": [
{
"script": "if <touching color [#FF0000]?> then\n change [health v] by (-1)\nend",
"explanation": "This script decreases the 'health' variable by 1 if the sprite touches any red color on the stage."
}
]
},
{
"block_name": "<color () is touching ()?>",
"block_type": "Sensing",
"op_code": "sensing_coloristouchingcolor",
"block_shape": "Boolean Block",
"functionality": "Checks whether a specific color on its sprite is touching another specified color on the stage or another sprite.",
"inputs": [
{"name": "COLOR1", "type": "color"},
{"name": "COLOR2", "type": "color"}
],
"example_standalone": "<color [#00FF00] is touching [#FF0000]?>",
"example_with_other_blocks": [
{
"script": "if <color [#00FF00] is touching [#FF0000]?> then\n say [Collision!]\nend",
"explanation": "This script makes the sprite say 'Collision!' if a green part of the sprite touches a red color elsewhere in the project."
}
]
},
{
"block_name": "<key () pressed?>",
"block_type": "Sensing",
"op_code": "sensing_keypressed",
"block_shape": "Boolean Block",
"functionality": "Checks if a specified keyboard key is currently being pressed.",
"inputs": [
{"name": "KEY_OPTION", "type": "dropdown",
"options": [
"space",
"up arrow",
"down arrow",
"right arrow",
"left arrow",
"any",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
]}
],
"example_standalone": "<key [space v] pressed?>",
"example_with_other_blocks": [
{
"script": "forever\n if <key [space v] pressed?> then\n broadcast [shoot v]\n end\nend",
"explanation": "This script continuously checks if the space key is pressed and, if so, sends a 'shoot' broadcast."
}
]
},
{
"block_name": "<mouse down?>",
"block_type": "Sensing",
"op_code": "sensing_mousedown",
"block_shape": "Boolean Block",
"functionality": "Checks if the computer mouse's primary button is being clicked while the cursor is over the stage.",
"inputs": null,
"example_standalone": "<mouse down?>",
"example_with_other_blocks": [
{
"script": "if <mouse down?> then\n go to mouse-pointer\nend",
"explanation": "This script makes the sprite follow the mouse pointer only when the mouse button is held down."
}
]
},
{
"block_name": "<[my list v] contains ()?>",
"block_type": "Data",
"op_code": "data_listcontainsitem",
"block_shape": "Boolean Block",
"functionality": "Checks if a list includes a specific item.",
"inputs": [
{"name": "LIST", "type": "dropdown"},
{"name": "ITEM", "type": "any"}
],
"example_standalone": "<[inventory v] contains [key]?>",
"example_with_other_blocks": [
{
"script": "if <[inventory v] contains [key]?> then\n say [You have the key!]\nend",
"explanation": "This script makes the sprite say 'You have the key!' if the 'inventory' list contains the item 'key'."
}
]
}
]
}