How to Define a Reporter Block

Материал из Поле цифровой дидактики

Scratch does not have the ability to define reporter blocks, but they can be simulated using variables.

Creating the Custom Block and Variable

define...Change...tothedescriptionyouwant.Addrequiredparametersifneeded....setreturnto...

Example

createacustommultiplicationblockdefineMultiplyn1n2setreturnton1*n2stopthisscriptwhenclickedaskWhatisthefirstnumber?andwaitsetnum1toansweraskWhatisthesecondnumber?andwaitsetnum2toanswerMultiplynum1num2sayreturn

You could also create a boolean:

definedoesn1equaln2?setreturnton1=n2stopthisscript

Then you could insert it into an if statement

ifreturn=truethenDosomethingend