Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vertigra committed May 8, 2024
2 parents 4db6949 + a9e6794 commit 91c138d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
35 changes: 35 additions & 0 deletions source/blocks/adam_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,41 @@

Blockly.defineBlocksWithJsonArray([

/*new eye pack*/
{
"type": "common_eye_new_eye",
"message0": "Новый экземпляр класса RobotEyeDisplay()",
"output": null,
"colour": 230,
"tooltip": "",
"helpUrl": ""
},

{
"type": "common_eye_run_anim",
"message0": "переменная класса RobotEyeDisplay() %1 анимация правого глаза %2 анимация левого глаза %3",
"args0": [
{
"type": "input_value",
"name": "instance_class_variable"
},
{
"type": "input_value",
"name": "right_eye_gif_path"
},
{
"type": "input_value",
"name": "left_path_gif_path"
}
],
"previousStatement": null,
"nextStatement": null,
"colour": 230,
"tooltip": "",
"helpUrl": ""
},


/**
* common_eye_pack
*
Expand Down
18 changes: 17 additions & 1 deletion source/generators/python/adam_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@

'use strict';
// If any new block imports any library, add that library name here.
Blockly.Python.addReservedWords('smbus, board, adafruit_extended_bus, ExtendedI2C, musicpy, os, sh, RHVoice, pygame');
Blockly.Python.addReservedWords('smbus, board, adafruit_extended_bus, ExtendedI2C, musicpy, os, sh, RHVoice, pygame, RobotEyeDisplay');

/* common_eye_new_eye */
Blockly.Python['common_eye_new_eye'] = function(block) {
Blockly.Python.definitions_['from_robot_eye_display_import_RobotEyeDisplay'] = 'from robot_eye_display import RobotEyeDisplay';
var code = 'RobotEyeDisplay()';
return [code, Blockly.Python.ORDER_NONE];
};

/* common_eye_run_anim */
Blockly.Python['common_eye_run_anim'] = function(block) {
var value_instance_class_variable = Blockly.Python.valueToCode(block, 'instance_class_variable', Blockly.Python.ORDER_ATOMIC);
var value_right_eye_gif_path = Blockly.Python.valueToCode(block, 'right_eye_gif_path', Blockly.Python.ORDER_NONE);
var value_left_path_gif_path = Blockly.Python.valueToCode(block, 'left_path_gif_path', Blockly.Python.ORDER_NONE);
var code = value_instance_class_variable + '.run(' + value_right_eye_gif_path + ', ' + value_left_path_gif_path + ')\n';
return code;
};

/**
* common_eye_pack
Expand Down
3 changes: 3 additions & 0 deletions source/generators/python/adam_three.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ Blockly.Python['controller_handle_command'] = function(block) {
return code;
};




Blockly.Python['controller_speed_variable'] = function(block) {
var number_speed = block.getFieldValue('speed');
var code = number_speed;
Expand Down

0 comments on commit 91c138d

Please sign in to comment.