|
@@ -13,6 +13,7 @@
|
|
|
</category>
|
|
|
<sep></sep>
|
|
|
<category name="循环" colour="#5ba55b">
|
|
|
+ <block type="controls_repeat_forever"></block>
|
|
|
<block type="controls_whileUntil"></block>
|
|
|
<block type="controls_for"></block>
|
|
|
</category>
|
|
@@ -93,6 +94,7 @@ export default {
|
|
|
// 代码生成器
|
|
|
myUpdateFunction(event) {
|
|
|
var code = Blockly.JavaScript.workspaceToCode(this.workspace);
|
|
|
+ debugger;
|
|
|
return code;
|
|
|
},
|
|
|
// 获取blockly工作区中的code和xml结构
|
|
@@ -230,6 +232,28 @@ export default {
|
|
|
return code;
|
|
|
};
|
|
|
|
|
|
+ Blockly.Blocks.controls_repeat_forever = {
|
|
|
+ init: function () {
|
|
|
+ this.jsonInit({
|
|
|
+ message0: Blockly.Msg.CONTROLS_REPEAT_FOREVER,
|
|
|
+ previousStatement: null,
|
|
|
+ nextStatement: null,
|
|
|
+ colour: "#5ba55b",
|
|
|
+ tooltip: Blockly.Msg.CONTROLS_REPEAT_FOREVER_TOOLTIP,
|
|
|
+ helpUrl: Blockly.Msg.CONTROLS_REPEAT_HELPURL,
|
|
|
+ });
|
|
|
+ this.appendStatementInput("DO").appendField(
|
|
|
+ Blockly.Msg.CONTROLS_REPEAT_INPUT_DO
|
|
|
+ );
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ Blockly.JavaScript.controls_repeat_forever = function (a) {
|
|
|
+ var d = Blockly.JavaScript.statementToCode(a, "DO");
|
|
|
+ d = Blockly.JavaScript.addLoopTrap(d, a);
|
|
|
+ return "while (true) {\n" + d + "}\n";
|
|
|
+ };
|
|
|
+
|
|
|
Blockly.Blocks["logic_number"] = {
|
|
|
init: function () {
|
|
|
this.appendDummyInput().appendField(
|