@@ -1672,7 +1672,7 @@ export default {
16721672 .setAlign (Blockly .ALIGN_CENTRE )
16731673 .appendField (new Blockly.FieldImage (" /static/images/blocks/musical_note.png" , 30 , 30 , { alt: " note" , flipRtl: " FALSE" }))
16741674 .appendField (" NOTA " )
1675- .appendField (new Blockly.FieldDropdown ([[" DO " ," C2" ], [" RE " ," D2" ], [" MI " ," E2" ], [" FA " ," F2" ], [" SOL " ," G2" ], [" LA " ," A3" ], [" SI " ," B3" ], [" DO+ " ," C3" ], [" RE+ " ," D3" ], [ " PAUSA " , " PAUSE " ]] ), " NAME" );
1675+ .appendField (new Blockly.FieldDropdown ([[" DO " ," C2" ], [" RE " ," D2" ], [" MI " ," E2" ], [" FA " ," F2" ], [" SOL " ," G2" ], [" LA " ," A3" ], [" SI " ," B3" ], [" DO+ " ," C3" ], [" RE+ " ," D3" ]] ), " NAME" );
16761676 this .setInputsInline (true );
16771677 this .setPreviousStatement (true , null );
16781678 this .setNextStatement (true , null );
@@ -1730,41 +1730,102 @@ export default {
17301730 return code;
17311731 };
17321732
1733- Blockly .Python [' coderbot_audio_listen' ] = function (block ) {
1734- // Boolean values true and false.
1735- var model = block .getFieldValue (' MODEL' );
1736- var code = sbsPrefix + ' get_audio().speech_recog_google(locale=\' ' + model + ' \' )' ;
1737- return [code, Blockly .Python .ORDER_ATOMIC ];
1738- };
1733+ Blockly .Blocks [' coderbot_music_note_std' ] = {
1734+ init : function () {
1735+ this .appendDummyInput ()
1736+ .appendField (new Blockly.FieldImage (" /static/images/blocks/musical_note.png" , 30 , 30 , { alt: " note" , flipRtl: " FALSE" }))
1737+ .appendField (" nota" )
1738+ .appendField (new Blockly.FieldDropdown ([[" DO " ," C2" ], [" RE " ," D2" ], [" MI " ," E2" ], [" FA " ," F2" ], [" FA # " ," F#2" ], [" SOL " ," G2" ], [" LA " ," A2" ], [" SI b " ," Bb2" ], [" SI " ," B2" ], [" DO+ " ," C3" ], [" RE+ " ," D3" ]]), " note" );
1739+ this .appendDummyInput ()
1740+ .appendField (" strumento" )
1741+ .appendField (new Blockly.FieldDropdown ([[" piano" ," piano" ], [" chitarra" ," guitar" ], [" flauto" ," flute" ]]), " instrument" );
1742+ this .appendValueInput (" duration" )
1743+ .setCheck (" Number" )
1744+ .setAlign (Blockly .ALIGN_CENTRE )
1745+ .appendField (" durata" );
1746+ this .appendDummyInput ()
1747+ .appendField (" secondi" );
1748+ this .setInputsInline (true );
1749+ this .setPreviousStatement (true , null );
1750+ this .setNextStatement (true , null );
1751+ this .setColour (345 );
1752+ this .setTooltip (" " );
1753+ this .setHelpUrl (" " );
1754+ }
1755+ };
17391756
1740- Blockly .Blocks [' coderbot_sonar_get_distance' ] = {
1741- /**
1742- * Block for get_distance function.
1743- * @this Blockly.Block
1744- */
1745- init : function () {
1746- this .setHelpUrl (Blockly .Msg .LOGIC_BOOLEAN_HELPURL );
1747- this .setColour (250 );
1748- this .appendDummyInput ()
1749- .appendField (Blockly .Msg .CODERBOT_SONAR_GET_DISTANCE )
1750- .appendField (new Blockly.FieldDropdown ([
1751- [Blockly .Msg .CODERBOT_SONAR_SENSOR_1 , " 0" ],
1752- [Blockly .Msg .CODERBOT_SONAR_SENSOR_2 , " 1" ],
1753- [Blockly .Msg .CODERBOT_SONAR_SENSOR_3 , " 2" ]
1754- ]), ' SONAR' );
1755- this .setOutput (true , ' Number' );
1756- this .setTooltip (Blockly .Msg .LOGIC_BOOLEAN_TOOLTIP );
1757- }
1758- };
17591757
1760- Blockly .Python [' coderbot_sonar_get_distance' ] = function (block ) {
1761- // Boolean values true and false.
1762- var sonar = block .getFieldValue (' SONAR' );
1763- var code = sbsPrefix + ' get_bot().get_sonar_distance(' + sonar + ' )' ;
1764- return [code, Blockly .Python .ORDER_ATOMIC ];
1765- };
1758+ Blockly .Python [' coderbot_music_note_std' ] = function (block ) {
1759+ var dropdown_note = block .getFieldValue (' note' );
1760+ var dropdown_instrument = block .getFieldValue (' instrument' );
1761+ var value_duration = Blockly .Python .valueToCode (block, ' duration' , Blockly .Python .ORDER_ATOMIC );
1762+ var alteration = " none"
1763+ var code = ' get_music().play_note(note="' + dropdown_note+ ' ", instrument="' + dropdown_instrument+ ' ", alteration="' + alteration+ ' ", duration=' + value_duration+ ' )\n ' ;
1764+ return code;
1765+ }
1766+
1767+
1768+ Blockly .Blocks [' coderbot_animal_verse_std' ] = {
1769+ init : function () {
1770+ this .appendDummyInput ()
1771+ .appendField (new Blockly.FieldImage (" /static/images/blocks/animal.png" , 30 , 30 , { alt: " note" , flipRtl: " FALSE" }))
1772+ .appendField (" nota" )
1773+ .appendField (new Blockly.FieldDropdown ([[" DO " ," C2" ], [" RE " ," D2" ], [" MI " ," E2" ], [" FA " ," F2" ], [" FA # " ," F#2" ], [" SOL " ," G2" ], [" LA " ," A2" ], [" SI b " ," Bb2" ], [" SI " ," B2" ], [" DO+ " ," C3" ], [" RE+ " ," D3" ] ]), " note" );
1774+ this .appendDummyInput ()
1775+ .appendField (" animale" )
1776+ .appendField (new Blockly.FieldDropdown ([[" Gatto" ," cat" ], [" Cane" ," dog" ], [" Dinosaur" ," dinosaur" ]]), " instrument" );
1777+ this .appendValueInput (" duration" )
1778+ .setCheck (" Number" )
1779+ .setAlign (Blockly .ALIGN_CENTRE )
1780+ .appendField (" durata" );
1781+ this .appendDummyInput ()
1782+ .appendField (" secondi" );
1783+ this .setInputsInline (true );
1784+ this .setPreviousStatement (true , null );
1785+ this .setNextStatement (true , null );
1786+ this .setColour (345 );
1787+ this .setTooltip (" " );
1788+ this .setHelpUrl (" " );
1789+ }
1790+ };
17661791
17671792
1793+ Blockly .Python [' coderbot_animal_verse_std' ] = function (block ) {
1794+ var dropdown_note = block .getFieldValue (' note' );
1795+ var dropdown_instrument = block .getFieldValue (' instrument' );
1796+ var value_duration = Blockly .Python .valueToCode (block, ' duration' , Blockly .Python .ORDER_ATOMIC );
1797+ var alteration = " none" ;
1798+ var code = ' get_music().play_animal(note="' + dropdown_note+ ' ", instrument="' + dropdown_instrument+ ' ", alteration="' + alteration+ ' ", duration=' + value_duration+ ' )\n ' ;
1799+ return code;
1800+ };
1801+
1802+
1803+ Blockly .Blocks [' coderbot_music_pause_std' ] = {
1804+ init : function () {
1805+ this .appendDummyInput ()
1806+ .appendField (new Blockly.FieldImage (" /static/images/blocks/pause_symbol.png" , 30 , 30 , { alt: " *" , flipRtl: " FALSE" }))
1807+ .appendField (" pausa" );
1808+ this .appendValueInput (" duration" )
1809+ .setCheck (" Number" )
1810+ .setAlign (Blockly .ALIGN_CENTRE )
1811+ .appendField (" durata" );
1812+ this .appendDummyInput ()
1813+ .appendField (" secondi" );
1814+ this .setInputsInline (true );
1815+ this .setColour (345 );
1816+ this .setPreviousStatement (true , null );
1817+ this .setNextStatement (true , null );
1818+ this .setTooltip (" " );
1819+ this .setHelpUrl (" " );
1820+ }
1821+
1822+ Blockly .Python [' coderbot_music_pause_std' ] = function (block ) {
1823+ var value_duration = Blockly .Python .valueToCode (block, ' duration' , Blockly .Python .ORDER_ATOMIC );
1824+ var code = ' get_music().play_pause(' + value_duration+ ' )\n ' ;
1825+ return code;
1826+ };
1827+
1828+
17681829
17691830
17701831
@@ -1876,6 +1937,41 @@ export default {
18761937 };
18771938
18781939
1940+ Blockly .Python [' coderbot_audio_listen' ] = function (block ) {
1941+ // Boolean values true and false.
1942+ var model = block .getFieldValue (' MODEL' );
1943+ var code = sbsPrefix + ' get_audio().speech_recog_google(locale=\' ' + model + ' \' )' ;
1944+ return [code, Blockly .Python .ORDER_ATOMIC ];
1945+ };
1946+
1947+ Blockly .Blocks [' coderbot_sonar_get_distance' ] = {
1948+ /**
1949+ * Block for get_distance function.
1950+ * @this Blockly.Block
1951+ */
1952+ init : function () {
1953+ this .setHelpUrl (Blockly .Msg .LOGIC_BOOLEAN_HELPURL );
1954+ this .setColour (250 );
1955+ this .appendDummyInput ()
1956+ .appendField (Blockly .Msg .CODERBOT_SONAR_GET_DISTANCE )
1957+ .appendField (new Blockly.FieldDropdown ([
1958+ [Blockly .Msg .CODERBOT_SONAR_SENSOR_1 , " 0" ],
1959+ [Blockly .Msg .CODERBOT_SONAR_SENSOR_2 , " 1" ],
1960+ [Blockly .Msg .CODERBOT_SONAR_SENSOR_3 , " 2" ]
1961+ ]), ' SONAR' );
1962+ this .setOutput (true , ' Number' );
1963+ this .setTooltip (Blockly .Msg .LOGIC_BOOLEAN_TOOLTIP );
1964+ }
1965+ };
1966+
1967+ Blockly .Python [' coderbot_sonar_get_distance' ] = function (block ) {
1968+ // Boolean values true and false.
1969+ var sonar = block .getFieldValue (' SONAR' );
1970+ var code = sbsPrefix + ' get_bot().get_sonar_distance(' + sonar + ' )' ;
1971+ return [code, Blockly .Python .ORDER_ATOMIC ];
1972+ };
1973+
1974+
18791975
18801976 },
18811977
0 commit comments