Skip to content

Commit e25423d

Browse files
committed
fix blocks basic
1 parent ca8b4f8 commit e25423d

File tree

2 files changed

+79
-23
lines changed

2 files changed

+79
-23
lines changed

src/assets/js/blockly/blocks.js

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -714,11 +714,7 @@ Blockly.Blocks.coderbot_camera_photoTake = {
714714
this.setHelpUrl('http://code.google.com/p/blockly/wiki/Turn');
715715
this.setColour(120);
716716
const di = this.appendDummyInput();
717-
if (Blockly.Blocks.CoderBotSettings.CODERBOT_PROG_LEVEL.indexOf('basic') >= 0) {
718-
di.appendField(new Blockly.FieldImage('/static/images/blocks/photo_take.png', 32, 32, '*'));
719-
} else {
720-
di.appendField(Blockly.Msg.CODERBOT_PHOTO_TAKE);
721-
}
717+
di.appendField(Blockly.Msg.CODERBOT_PHOTO_TAKE);
722718
this.setPreviousStatement(true);
723719
this.setNextStatement(true);
724720
this.setTooltip(('CoderBot_PhotoTooltip'));
@@ -730,18 +726,32 @@ Blockly.Python.coderbot_camera_photoTake = function (block) {
730726
return `${sbsPrefix}get_cam().photo_take()\n`;
731727
};
732728

729+
Blockly.Blocks.coderbot_basic_camera_photoTake = {
730+
// Block for taking a picture.
731+
init() {
732+
this.setHelpUrl('http://code.google.com/p/blockly/wiki/Turn');
733+
this.setColour(120);
734+
const di = this.appendDummyInput();
735+
di.appendField(new Blockly.FieldImage('/static/images/blocks/photo_take.png', 32, 32, '*'));
736+
this.setPreviousStatement(true);
737+
this.setNextStatement(true);
738+
this.setTooltip(('CoderBot_PhotoTooltip'));
739+
},
740+
};
741+
742+
Blockly.Python.coderbot_camera_basic_photoTake = function (block) {
743+
// Generate Python for turning left or right.
744+
return `${sbsPrefix}get_cam().photo_take()\n`;
745+
};
746+
733747
Blockly.Blocks.coderbot_camera_videoRec = {
734748
// Block for recording a video (start).
735749
init() {
736750
this.setHelpUrl('http://code.google.com/p/blockly/wiki/Turn');
737751
this.setColour(120);
738752

739753
const di = this.appendDummyInput();
740-
if (Blockly.Blocks.CoderBotSettings.CODERBOT_PROG_LEVEL.indexOf('basic') >= 0) {
741-
di.appendField(new Blockly.FieldImage('/static/images/blocks/video_rec.png', 32, 32, '*'));
742-
} else {
743-
di.appendField(Blockly.Msg.CODERBOT_VIDEO_REC);
744-
}
754+
di.appendField(Blockly.Msg.CODERBOT_VIDEO_REC);
745755
this.setPreviousStatement(true);
746756
this.setNextStatement(true);
747757
this.setTooltip(('CoderBot_VideoTooltip'));
@@ -753,18 +763,33 @@ Blockly.Python.coderbot_camera_videoRec = function (block) {
753763
return `${sbsPrefix}get_cam().video_rec()\n`;
754764
};
755765

766+
Blockly.Blocks.coderbot_basic_camera_videoRec = {
767+
// Block for recording a video (start).
768+
init() {
769+
this.setHelpUrl('http://code.google.com/p/blockly/wiki/Turn');
770+
this.setColour(120);
771+
772+
const di = this.appendDummyInput();
773+
di.appendField(new Blockly.FieldImage('/static/images/blocks/video_rec.png', 32, 32, '*'));
774+
this.setPreviousStatement(true);
775+
this.setNextStatement(true);
776+
this.setTooltip(('CoderBot_VideoTooltip'));
777+
},
778+
};
779+
780+
Blockly.Python.coderbot_basic_camera_videoRec = function (block) {
781+
// Generate Python for turning left or right.
782+
return `${sbsPrefix}get_cam().video_rec()\n`;
783+
};
784+
756785
Blockly.Blocks.coderbot_camera_videoStop = {
757786
// Block for recording a video (stop).
758787
init() {
759788
this.setHelpUrl('http://code.google.com/p/blockly/wiki/Turn');
760789
this.setColour(120);
761790

762791
const di = this.appendDummyInput();
763-
if (Blockly.Blocks.CoderBotSettings.CODERBOT_PROG_LEVEL.indexOf('basic') >= 0) {
764-
di.appendField(new Blockly.FieldImage('/static/images/blocks/video_stop.png', 32, 32, '*'));
765-
} else {
766-
di.appendField(Blockly.Msg.CODERBOT_VIDEO_STOP);
767-
}
792+
di.appendField(Blockly.Msg.CODERBOT_VIDEO_STOP);
768793
this.setPreviousStatement(true);
769794
this.setNextStatement(true);
770795
this.setTooltip(('CoderBot_VideoTooltip'));
@@ -776,6 +801,25 @@ Blockly.Python.coderbot_camera_videoStop = function (block) {
776801
return `${sbsPrefix}get_cam().video_stop()\n`;
777802
};
778803

804+
Blockly.Blocks.coderbot_basic_camera_videoStop = {
805+
// Block for recording a video (stop).
806+
init() {
807+
this.setHelpUrl('http://code.google.com/p/blockly/wiki/Turn');
808+
this.setColour(120);
809+
810+
const di = this.appendDummyInput();
811+
di.appendField(Blockly.Msg.CODERBOT_VIDEO_STOP);
812+
this.setPreviousStatement(true);
813+
this.setNextStatement(true);
814+
this.setTooltip(('CoderBot_VideoTooltip'));
815+
},
816+
};
817+
818+
Blockly.Python.coderbot_basic_camera_videoStop = function (block) {
819+
// Generate Python for turning left or right.
820+
return `${sbsPrefix}get_cam().video_stop()\n`;
821+
};
822+
779823
Blockly.Blocks.coderbot_adv_pathAhead = {
780824
/**
781825
* Block for pathAhead function.
@@ -1278,11 +1322,7 @@ Blockly.Blocks.coderbot_audio_play = {
12781322
this.setColour(220);
12791323
const vi = this.appendValueInput('FILENAME');
12801324
vi.setCheck('String');
1281-
if (Blockly.Blocks.CoderBotSettings.CODERBOT_PROG_LEVEL.indexOf('basic') >= 0) {
1282-
vi.appendField(new Blockly.FieldImage('/static/images/blocks/play.png', 32, 32, '*'));
1283-
} else {
1284-
vi.appendField(Blockly.Msg.CODERBOT_AUDIO_PLAY_FILE);
1285-
}
1325+
vi.appendField(Blockly.Msg.CODERBOT_AUDIO_PLAY_FILE);
12861326
this.setPreviousStatement(true);
12871327
this.setNextStatement(true);
12881328
this.setTooltip(('CoderBot_audio_play_Tooltip'));

src/assets/toolbox_adv.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,16 +728,28 @@
728728
{
729729
"kind": "block",
730730
"type": "coderbot_basic_audio_say"
731-
}
731+
},
732+
{
733+
"kind": "block",
734+
"type": "coderbot_basic_camera_photoTake"
735+
},
736+
{
737+
"kind": "block",
738+
"type": "coderbot_basic_camera_videoRec"
739+
},
740+
{
741+
"kind": "block",
742+
"type": "coderbot_basic_camera_videoStop"
743+
}
732744
]
733745
},
734746
{
735747
"kind": "category",
736748
"name": "Camera",
737749
"colour": "120",
738750
"contents": [{
739-
"kind": "block",
740-
"type": "coderbot_camera_photoTake"
751+
"kind": "block",
752+
"type": "coderbot_camera_photoTake"
741753
},
742754
{
743755
"kind": "block",
@@ -901,6 +913,10 @@
901913
{
902914
"kind": "block",
903915
"type": "coderbot_atmega_set_output"
916+
},
917+
{
918+
"kind": "block",
919+
"type": "coderbot_atmega_set_led"
904920
}
905921
]
906922
},

0 commit comments

Comments
 (0)