gobstones-blockly 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/htmls/gs-element-blockly.html +65 -4
- data/lib/gobstones/blockly/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d419151d788c79159a33541aaabad83c5ba6dac3983ec745b81bab7077c9210d
|
4
|
+
data.tar.gz: 707a529e4d4d693c090c804b8ea70261346b6014e58b37505184452f1b6dec96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fcb41fb972763cab3349ddac30cd45a2b921dfba725343a77eeba576dfb8b74bb8a2a1f3e999de2ff4cab2d064f79984f0622ea60031a6ec8b27b1eaf7493e9
|
7
|
+
data.tar.gz: aefbddac2244fb23b4ba3598aed08b2a1925b7af4c2cedc850ef89b6b02518c47f9d555064ab35bf4f57c8a6c3e49866afbef95c5958a5e488758bcc36b16e6c
|
@@ -52,6 +52,7 @@ Example:
|
|
52
52
|
<category name="Repeticiones">
|
53
53
|
<block type="RepeticionSimple"></block>
|
54
54
|
<block type="RepeticionCondicional"></block>
|
55
|
+
<block type="ForEach"></block>
|
55
56
|
</category>
|
56
57
|
<category name="Asignación">
|
57
58
|
<block type="Asignacion"></block>
|
@@ -4066,6 +4067,15 @@ Blockly.createBlockSvg = function(workspace, name, f) {
|
|
4066
4067
|
newBlock.render();
|
4067
4068
|
};
|
4068
4069
|
|
4070
|
+
const createVariable = (workspace, name) => {
|
4071
|
+
Blockly.createBlockSvg(workspace, 'variables_get', b => {
|
4072
|
+
b.setFieldValue(name, 'VAR');
|
4073
|
+
b.moveBy(10,5);
|
4074
|
+
});
|
4075
|
+
}
|
4076
|
+
|
4077
|
+
// ---
|
4078
|
+
|
4069
4079
|
Blockly.Blocks.Program = {
|
4070
4080
|
init: function () {
|
4071
4081
|
this.jsonInit({
|
@@ -4938,6 +4948,52 @@ Blockly.Blocks.List = {
|
|
4938
4948
|
}
|
4939
4949
|
};
|
4940
4950
|
|
4951
|
+
Blockly.Blocks.ForEach = {
|
4952
|
+
init: function () {
|
4953
|
+
this.jsonInit({
|
4954
|
+
type: "Statement",
|
4955
|
+
previousStatement: "Statement",
|
4956
|
+
nextStatement: "Statement",
|
4957
|
+
message0: 'Repetir para cada %1 %2 %3',
|
4958
|
+
args0: [
|
4959
|
+
{
|
4960
|
+
"type": "field_input",
|
4961
|
+
"name": "varName",
|
4962
|
+
"text": "elemento"
|
4963
|
+
},
|
4964
|
+
{
|
4965
|
+
type: 'input_dummy'
|
4966
|
+
},
|
4967
|
+
{
|
4968
|
+
"type": "field_label",
|
4969
|
+
"text": "en"
|
4970
|
+
},
|
4971
|
+
]
|
4972
|
+
});
|
4973
|
+
|
4974
|
+
this.setColour(Blockly.CUSTOM_COLORS.ForEach || Blockly.CUSTOM_COLORS.controlStructure);
|
4975
|
+
this.appendValueInput('list');
|
4976
|
+
this.appendStatementInput('block').setCheck(["Statement"]);
|
4977
|
+
this.setInputsInline(true);
|
4978
|
+
|
4979
|
+
var self = this;
|
4980
|
+
|
4981
|
+
const handIcon = "hand.png";
|
4982
|
+
var createGetterButton = new Blockly.FieldImage(
|
4983
|
+
getLocalMediaUrl(this, handIcon),
|
4984
|
+
getLocalMediaSize(handIcon),
|
4985
|
+
getLocalMediaSize(handIcon),
|
4986
|
+
"Obtener variable",
|
4987
|
+
function() {
|
4988
|
+
var name = self.getFieldValue('varName');
|
4989
|
+
createVariable(self.workspace, name);
|
4990
|
+
}
|
4991
|
+
);
|
4992
|
+
|
4993
|
+
this.inputList[0].appendField(createGetterButton);
|
4994
|
+
}
|
4995
|
+
};
|
4996
|
+
|
4941
4997
|
function createSingleParameterExpressionBlock(blockText,returnType, colorType = "operator"){
|
4942
4998
|
return {
|
4943
4999
|
init: function () {
|
@@ -5117,10 +5173,7 @@ Blockly.Blocks.Asignacion = {
|
|
5117
5173
|
},
|
5118
5174
|
|
5119
5175
|
createVariableBlock: function(name) {
|
5120
|
-
return
|
5121
|
-
b.setFieldValue(name, 'VAR');
|
5122
|
-
b.moveBy(10,5);
|
5123
|
-
});
|
5176
|
+
return createVariable(this.workspace, name);
|
5124
5177
|
}
|
5125
5178
|
};
|
5126
5179
|
|
@@ -5578,6 +5631,14 @@ Blockly.GobstonesLanguage.List = function(block) {
|
|
5578
5631
|
return [code, Blockly.GobstonesLanguage.ORDER_ATOMIC];
|
5579
5632
|
};
|
5580
5633
|
|
5634
|
+
Blockly.GobstonesLanguage.ForEach = function (block) {
|
5635
|
+
let body = Blockly.GobstonesLanguage.statementToCode(block, 'block');
|
5636
|
+
var varName = block.getFieldValue('varName');
|
5637
|
+
var list = Blockly.GobstonesLanguage.valueToCode(block, 'list', Blockly.GobstonesLanguage.ORDER_NONE) || '';
|
5638
|
+
|
5639
|
+
return `foreach ${varName} in ${list} {\n${body}}\n`;
|
5640
|
+
};
|
5641
|
+
|
5581
5642
|
Blockly.GobstonesLanguage.OperadorDeComparacion = function (block) {
|
5582
5643
|
var code =
|
5583
5644
|
(Blockly.GobstonesLanguage.valueToCode(block, 'arg1', Blockly.GobstonesLanguage.ORDER_RELATIONAL) || '()') +
|