My Blocks Icon of block

我的指令
My Block

在工作區域中是可以選擇若干的指令並組合成自定的指令集,並加以自定的圖像表示.例如,"機器人動作"的自定指令就可以視為一個移動指令(控制機器人輪子轉動)和一個聲音指令(負責在機器人走了一段距離後撥放聲音檔)的組合.
The My Block Builder lets you take a number of blocks you select in the work area and group them together into your own My Block with a customized icon. For example, a My Block you create called “Robot Motion” might group a Move block (to control your robot’s wheels) together with a Sound block (that plays a sound file when the robot has traveled a certain distance).

使用同一個機器人來執行新程式時,只需從自訂面板上拖曳自訂的"機器人動作"指令就可以執行同樣的動作.因為所有其他的參數都已經設定就緒.
When you create a new program using the same robot, you can just drag the “Robot Motion” block from the Custom palette and you will be done programming this part of the robot’s motion because you already set all of the parameters in the My Block.

等建立起一套自訂指令的函式庫後,便可以應用在其他的程式或是跟其他的MINDSTORMS使用者交流.
Over time you may develop a library of My Blocks that you can use in other programs and trade with other MINDSTORMS users.

建立我的指令
Creating a My Block

  1. 首先選取若干個執行無誤的指令.例如在剛才的例子中,可能要選取幾個移動只例來控制機器人的動作,並且群組化後放進我的指令中.
    First select a number of blocks that logically go together. As in the example above, you might choose a number of blocks that control your robot’s movement and choose to group them into a My Block.
  2. 假設有個矩形來圈選所需的指令,先以滑鼠點下其中一個角落,接著按住按鍵並移動滑鼠到對角線位置的角落.而在這個矩形範圍內的指令都會被選取.僅有部分被選到的指令也會被包含在內.
    Select the blocks by placing your mouse pointer to one corner of an imaginary rectangle that will surround all of the blocks you want in the My Block. Hold down your mouse button and sweep the pointer to the opposite corner of the imaginary rectangle, surrounding the blocks. When you release the mouse button, all of the blocks for your new My Block should be selected. Remember that a selection that partly covers a block will include that block in the My Block.

    Image of mouse selecting Move and Sound blocks

  3. 在這些指令被選取時,從編輯選單中使用"建立我的指令"功能,這個動作會打開建立我的指令的精靈視窗(下圖).
    With the blocks selected, choose the Make a New My Block command from the Edit menu at the top of the NXT software interface. This will open the first My Block Builder wizard screen (shown below).

    Image of first My Block Builder screen showing selected Move and Sound blocks

  4. 輸入指令的新名稱並簡短描述功能.例如:"這個指令控制Tribot的馬達並會在機器人走了一公尺後發出聲音".接著下個步驟.
    Give your new My Block a name and write a short description of what it does. For example: “This block controls the motors of a TriBot and plays a tone when the robot has traveled one meter.” Click Next to move to the next step.

    Image of second My Block Builder screen showing the icon design screen

  5. 接下來設計指令的圖示,拖曳一兩個圖示到編輯區內.使用鍵盤的方向鍵可以微調圖示位置.而右邊的圖像顯示出最後的結果.設計好後按下"完成"鍵.新的自訂指令就會出現在自訂面板上(點選程式面板最右邊的標籤即可).
    Next, design your new My Block’s icon. Use your mouse to drag an icon or two into the editing box. Your keyboard's arrow keys will allow you to fine tune the positioning of the icon(s). The example block to the right shows what it will look like when you are done. Click Drag an icon or two into the editing box at the top of the window. Use your keyboard's arrow keys to adjust each icons final position. The graphic to the right shows what the block will look like. Click Finish when you are done. Your new My Block will appear in your current program and in the Custom palette, which is accessible by clicking the right-most tab at the bottom of the programming palette. (See image below.)

    Image showing the palette tabs and highlighted Custom palette tab

注意:選取範圍內的輸入輸出資料線都會成為新指令的輸入輸出資料線.這些連接埠都會顯示在新指令的資料集線器上.
Note: remember that any input or output data wires that crossed the selection frame (that first enclosed the blocks making up your My Block) will be created as input and output plugs on your new My Block’s data hub.

如果想要更改可用的連接埠,則需要重新建立我的指令並同時選取所需的連接埠跟對應的資料線.
If you want to change the available plugs of a My Block, you will have to create the My Block again, this time with the right plugs (and corresponding data wires) extending out of the selected area.

編輯自己現有的指令
Editing an Existing My Block

如果想編輯我的指令內的執行動作時,可以雙擊我的指令或是從編輯選單中選取"編輯所選的我的指令"功能.如果只要改變圖示,則需使用編輯選單中的"編輯我的指令圖示"功能,此時就會出現我的指令編輯器來編輯.
If you want to change the performance of a My Block, you can edit the blocks it contains by double-clicking the My Block or by choosing Edit Selected My Block from the Edit menu. If you just want to change a My Block’s icon, you should select the block and choose the Edit My Block Icon command in the Edit menu––this will launch the My Block Builder where you can make any changes.

管理客置面板
Managing the Custom Palette

編輯選單中的"管理客置面板"指令可以增加或刪除自訂面板中我的指令.而要寄給朋友所編輯的新指令時,只需複製指令並附在信件中.若是從朋友那接收到新指令時,把該指令拖曳到我的指令資料夾內即可使用.
You can add and delete My Blocks from the Custom Palette by selecting the Manage Custom Palette command in the Edit menu. To send a My Block to a friend, make a copy of the desired My Block and attach it to an email message. If you receive a My Block from a friend, choose the Manage Custom Palette command and drag the new My Block to the My Blocks folder.

在指令資料夾下也可以建立新的資料夾,這樣便會在自訂面板中建立新的子面板.要自定這些新的子面板的外觀時,要在每個子資料夾下放置兩個45X45的PNG(Portable Network Graphics)檔: "PaletteIcon.png", "PaletteIconHilight.png" 並可以在同樣的資料夾內建立文字檔"PaletteIcon.txt"來顯示提示文字.
PaletteIcon.txtYou can create new sub palettes in the Custom palette by creating a new folder in the Block folder. Customize each sub palette's appearence by placing two 45x45 pixel Portable Network Graphics (PNG) files (called PaletteIcon.png and PaletteIconHilight.png) in the sub palette's folder. You can specify a tooltip for each custom sub palette by placing a text file call PaletteIcon.txt (with the tooltip text in it) in the same folder.