Skip to content

Commit 4aa83a3

Browse files
committed
Added a comment block
1 parent 1f9db18 commit 4aa83a3

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

js/xrp_blockly_toolbox.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ var baseToolbox = {
274274
{
275275
"kind": "CATEGORY",
276276
"contents": [
277+
{
278+
"kind": "BLOCK",
279+
"type": "comment"
280+
},
277281
{
278282
"kind": "BLOCK",
279283
"type": "xrp_sleep",
@@ -422,7 +426,13 @@ var baseToolbox = {
422426
},
423427
{
424428
"kind": "CATEGORY",
429+
"name": "Text",
430+
"colour": "#5ba58c", // seafoam green
425431
"contents": [
432+
{
433+
"kind": "BLOCK",
434+
"type": "comment"
435+
},
426436
{
427437
"kind": "BLOCK",
428438
"blockxml": "<block type=\"text_print\">\n <value name=\"TEXT\">\n <shadow type=\"text\">\n <field name=\"TEXT\">abc</field>\n </shadow>\n </value>\n </block>",
@@ -483,9 +493,7 @@ var baseToolbox = {
483493
"blockxml": "<block type=\"text_prompt_ext\">\n <mutation type=\"TEXT\"></mutation>\n <field name=\"TYPE\">TEXT</field>\n <value name=\"TEXT\">\n <shadow type=\"text\">\n <field name=\"TEXT\">abc</field>\n </shadow>\n </value>\n </block>",
484494
"type": "text_prompt_ext"
485495
}
486-
],
487-
"name": "Text",
488-
"colour": "#5ba58c" // seafoam green
496+
]
489497
},
490498
{
491499
"kind": "CATEGORY",

js/xrp_blocks.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
This file creates each Block item for Blockly.
43
You can set and update the colors here based off the HUE value.
@@ -619,3 +618,16 @@ Blockly.Blocks['xrp_sleep'] = {
619618
// Lists --> eggplant purple
620619
// Variables --> grey
621620
// Functions --> medium purple
621+
622+
Blockly.Blocks['comment'] = {
623+
init: function() {
624+
this.appendDummyInput()
625+
.appendField("Comment")
626+
.appendField(new Blockly.FieldTextInput(""), "TEXT");
627+
this.setColour(60); // yellow
628+
this.setPreviousStatement(true, null);
629+
this.setNextStatement(true, null);
630+
this.setTooltip("Add a comment to your code.");
631+
this.setHelpUrl("");
632+
}
633+
};

js/xrp_blocks_python.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,9 @@ Blockly.Python['xrp_sleep'] = function (block) {
367367
return code;
368368
};
369369

370+
Blockly.Python['comment'] = function(block) {
371+
var text = block.getFieldValue('TEXT');
372+
return '# ' + text + '\n';
373+
};
374+
370375

0 commit comments

Comments
 (0)