我的积木#
介绍#
My Blocks is the equivalent to functions in Python. My Blocks group blocks into reusable, efficient sections of blocks designed to perform a specific task. My Blocks can be called multiple times within a program, making project organization easier, and helping to avoid repeated blocks.
定义 myBlock
myBlock
参数 |
描述 |
|---|---|
块名称 |
A name you give to your My Block. |
参数 |
可选。函数调用时接受输入值的变量,允许将数据传递到函数中。它可以是文本、数字或布尔值。 |
定义和调用我的块#
我的积木#
If a My Block does not require input, you can define it without parameters.
定义 greeting
[Define a My Block to display a message]
在屏幕上打印 [Hello!]▶
当开始
[Call a My Block to display the message]
greeting
我的带参数的块#
Parameters let you give a My Block the information it needs to work, such as how many times to complete a sequence of movements. For example, a My Block could use a number parameter to tell the drone how high to fly. This lets you use the same My Block in different ways depending on what values you give it.
定义 Divide by 3 (number) :: custom
[Display the quotient with two decimals.]
在控制台上设定打印精度为 [0.01 v]
在控制台上打印 ((number) [/ v] (3))◀ 并设定光标为下一行
当开始
[Set the equation's dividend.]
Divide by 3 [4]
Divide by 3 [12]