Discuss Scratch
- Discussion Forums
- » Suggestions
- » Custom block variables
- stevetheipad
-
500+ posts
Custom block variables
I'm a little confused by the custom block number, string and boolean inputs. Can someone be so kind as to explain them to me? I just don't get what they do/how to set them.
- mrsteve
-
100+ posts
Custom block variables
These blocks are parameters to your block/function. Based on the datatype you choose (ie: number, string, or boolean) it tells your custom block what kinds of objects you expect to drop into the your custom block.
For example say you use the <move steps> block in the motion category and the <say > block from looks. as part of your custom block. Then you would use two parameters one a number and one a string. You would then click on the “number1” in the custom block and drag it into the number “area” of the <move steps> block. You could also drag the “string1” in the custom block and drag it into the string area of the "say “ block.
Notice I said ”what kinds of objects you expect to drop in“ not ”can drop in“. Since a variable can be a number or a string, you could create a custom block which expects a number but the variable you pass is a string (which the interface allows) and thus wind up with a case where you ask a sprite to ”Move steps". It doesn't complain when this executes, which is interesting, and it doesn't move either.
For example say you use the <move steps> block in the motion category and the <say > block from looks. as part of your custom block. Then you would use two parameters one a number and one a string. You would then click on the “number1” in the custom block and drag it into the number “area” of the <move steps> block. You could also drag the “string1” in the custom block and drag it into the string area of the "say “ block.
Notice I said ”what kinds of objects you expect to drop in“ not ”can drop in“. Since a variable can be a number or a string, you could create a custom block which expects a number but the variable you pass is a string (which the interface allows) and thus wind up with a case where you ask a sprite to ”Move steps". It doesn't complain when this executes, which is interesting, and it doesn't move either.
- natalie
-
100+ posts
Custom block variables
There is also an explanation of the customized blocks (Make a Blocks) on this page– some cosmetic details have changed, but the basic concepts are there:
http://mv.ezproxy.com.ezproxyberklee.flo.org/prototype#make-blocks
http://mv.ezproxy.com.ezproxyberklee.flo.org/prototype#make-blocks
Last edited by natalie (Nov. 6, 2012 14:08:05)
- scimonster
-
1000+ posts
Custom block variables
mrsteveThat's because it treats the string as numerical value 0.
It doesn't complain when this executes, which is interesting, and it doesn't move either.
- Hardmath123
-
1000+ posts
Custom block variables
Exactly. See http://mv.ezproxy.com.ezproxyberklee.flo.org/wiki/Casting.
@Steve: They are basically arguments to your function.
You add an input, and it shows up as a text box in the block, like the (10) in Move (10) steps.
@Steve: They are basically arguments to your function.

- Discussion Forums
- » Suggestions
-
» Custom block variables