Therefore it is convenient to have a custom block (user defined block) to display the dice 's eyes on the LED. To exceed the beginner level, it is essential to use this custom block function. A simple example is shown below.
In the following, the function "show_pips_on_dice" was defined as a custom block. The argument denotes the number of pips of the dice. Every time you press button A, the eyes of the dice are displayed in ascending order. Thanks to the custom block, you can write it concisely like this.
Using custom block for displaying pips on a dice
The setting of this custom block is performed as shown below. Define this function "show_pips_on_dice (n: number)" in the namespace "custom". Then you can use (call) this function as a block from the menu "Custom". This definition content is stored in a file called "custom.ts".
Definition of a custom block for displaying pips on a dice