// Define motion blocks
Blockly.Blocks['motion_movesteps'] = {
init: function() {
this.appendValueInput("STEPS")
.setCheck("Number")
.appendField("move");
this.appendDummyInput()
.appendField("steps");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip('');
this.setHelpUrl('');
}
};
Blockly.Blocks['motion_moveleft'] = {
init: function() {
this.appendDummyInput()
.appendField("move left");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip('');
this.setHelpUrl('');
}
};
Blockly.Blocks['motion_moveright'] = {
init: function() {
this.appendDummyInput()
.appendField("move right");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip('');
this.setHelpUrl('');
}
};
Blockly.Blocks['motion_turnleft'] = {
init: function() {
this.appendDummyInput()
.appendField("turn left");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip('');
this.setHelpUrl('');
}
};
Blockly.Blocks['motion_turnright'] = {
init: function() {
this.appendDummyInput()
.appendField("turn right");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip('');
this.setHelpUrl('');
}
};
// JavaScript code generation for motion blocks
javascriptGenerator['motion_movesteps'] = function(block) {
var value_steps = javascriptGenerator.valueToCode(block, 'STEPS', javascriptGenerator.ORDER_ATOMIC);
var code = `moveSteps(${value_steps});\n`;
console.log(code); // Add console log for debugging
return code;
};
javascriptGenerator['motion_moveleft'] = function(block) {
var code = 'moveLeft();\n';
return code;
};
javascriptGenerator['motion_moveright'] = function(block) {
var code = 'moveRight();\n';
return code;
};
javascriptGenerator['motion_turnleft'] = function(block) {
var code = 'turnLeft();\n';
return code;
};
javascriptGenerator['motion_turnright'] = function(block) {
var code = 'turnRight();\n';
return code;
};