Skip to content

Commit 0b8258d

Browse files
MicheleCarboneraMicheleCarbonera
authored andcommitted
Add note and instr. blockly
1 parent 2bf988d commit 0b8258d

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

src/components/Activity.vue

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,75 @@ export default {
16981698
var code = sbsPrefix + 'get_bot().get_sonar_distance(' + sonar + ')';
16991699
return [code, Blockly.Python.ORDER_ATOMIC];
17001700
};
1701+
1702+
1703+
1704+
1705+
1706+
1707+
1708+
1709+
1710+
1711+
1712+
1713+
1714+
1715+
Blockly.Blocks['coderbot_music_note_adv'] = {
1716+
init: function() {
1717+
this.appendDummyInput()
1718+
.appendField("nota")
1719+
.appendField(new Blockly.FieldDropdown([["DO","C2"], ["RE","D2"], ["MI","E2"], ["FA","F2"], ["SOL","G2"], ["LA","A2"], ["SI","B2"], ["DO+","C3"], ["RE+","D3"]]), "note")
1720+
.appendField(new Blockly.FieldDropdown([["nessuna alterazione","none"], ["b","bmolle"], ["#","diesis"]]), "alteration");
1721+
this.appendValueInput("instrument")
1722+
.setCheck("String")
1723+
.appendField("strumento");
1724+
this.appendValueInput("duration")
1725+
.setCheck("Number")
1726+
.setAlign(Blockly.ALIGN_CENTRE)
1727+
.appendField("durata");
1728+
this.appendDummyInput()
1729+
.appendField("secondi");
1730+
this.setInputsInline(true);
1731+
this.setPreviousStatement(true, null);
1732+
this.setNextStatement(true, null);
1733+
this.setColour(345);
1734+
this.setTooltip("");
1735+
this.setHelpUrl("");
1736+
}
1737+
};
1738+
1739+
Blockly.JavaScript['coderbot_music_note_adv'] = function(block) {
1740+
var dropdown_note = block.getFieldValue('note');
1741+
var dropdown_alteration = block.getFieldValue('alteration');
1742+
var value_instrument = Blockly.JavaScript.valueToCode(block, 'instrument', Blockly.JavaScript.ORDER_ATOMIC);
1743+
var value_duration = Blockly.JavaScript.valueToCode(block, 'duration', Blockly.JavaScript.ORDER_ATOMIC);
1744+
1745+
var code = 'get_music().play_note(note="'+dropdown_note+'",instrument="'+dropdown_instrument+'",duration="'+value_duration+'",alteration="'+dropdown_alteration+')\n';
1746+
return code;
1747+
};
1748+
1749+
Blockly.Blocks['coderbot_music_instrument_adv'] = {
1750+
init: function() {
1751+
this.appendDummyInput()
1752+
.appendField(new Blockly.FieldDropdown([["guitar","guitar"], ["piano","piano"], ["flauto","flute"]]), "instrument");
1753+
this.setInputsInline(true);
1754+
this.setOutput(true, null);
1755+
this.setColour(345);
1756+
this.setTooltip("");
1757+
this.setHelpUrl("");
1758+
}
1759+
};
1760+
1761+
Blockly.JavaScript['coderbot_music_instrument_adv'] = function(block) {
1762+
var dropdown_instrument = block.getFieldValue('instrument');
1763+
var code = dropdown_instrument;
1764+
return [code, Blockly.JavaScript.ORDER_NONE];
1765+
};
1766+
1767+
1768+
1769+
17011770
},
17021771
17031772
toggleSidebar() {

0 commit comments

Comments
 (0)