parent
eb3a86a379
commit
9cb978b071
@ -148,53 +148,7 @@ Blockly["Arduino"].init = function (workspace) {
|
|||||||
// Blockly.Names.DEVELOPER_VARIABLE_TYPE));
|
// Blockly.Names.DEVELOPER_VARIABLE_TYPE));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const doubleVariables = workspace.getVariablesOfType("Number");
|
|
||||||
let i = 0;
|
|
||||||
let variableCode = "";
|
|
||||||
for (i = 0; i < doubleVariables.length; i += 1) {
|
|
||||||
variableCode +=
|
|
||||||
"double " +
|
|
||||||
Blockly["Arduino"].nameDB_.getName(
|
|
||||||
doubleVariables[i].getId(),
|
|
||||||
Blockly.Variables.NAME_TYPE
|
|
||||||
) +
|
|
||||||
" = 0; \n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
const stringVariables = workspace.getVariablesOfType("String");
|
|
||||||
for (i = 0; i < stringVariables.length; i += 1) {
|
|
||||||
variableCode +=
|
|
||||||
"String " +
|
|
||||||
Blockly["Arduino"].nameDB_.getName(
|
|
||||||
stringVariables[i].getId(),
|
|
||||||
Blockly.Variables.NAME_TYPE
|
|
||||||
) +
|
|
||||||
' = ""; \n\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
const booleanVariables = workspace.getVariablesOfType("Boolean");
|
|
||||||
for (i = 0; i < booleanVariables.length; i += 1) {
|
|
||||||
variableCode +=
|
|
||||||
"boolean " +
|
|
||||||
Blockly["Arduino"].nameDB_.getDistinctName(
|
|
||||||
booleanVariables[i].getId(),
|
|
||||||
Blockly.Variables.NAME_TYPE
|
|
||||||
) +
|
|
||||||
" = false; \n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
const colourVariables = workspace.getVariablesOfType("Colour");
|
|
||||||
for (i = 0; i < colourVariables.length; i += 1) {
|
|
||||||
variableCode +=
|
|
||||||
"RGB " +
|
|
||||||
Blockly["Arduino"].nameDB_.getName(
|
|
||||||
colourVariables[i].getId(),
|
|
||||||
Blockly.Variables.NAME_TYPE
|
|
||||||
) +
|
|
||||||
" = {0, 0, 0}; \n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
Blockly["Arduino"].variablesInitCode_ = variableCode;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,11 +21,8 @@ class Toolbox extends React.Component {
|
|||||||
[`${Blockly.Msg.variable_LONG}`, "long"],
|
[`${Blockly.Msg.variable_LONG}`, "long"],
|
||||||
[`${Blockly.Msg.variable_DECIMAL}`, "float"],
|
[`${Blockly.Msg.variable_DECIMAL}`, "float"],
|
||||||
[`${Blockly.Msg.variables_TEXT}`, "String"],
|
[`${Blockly.Msg.variables_TEXT}`, "String"],
|
||||||
[`${Blockly.Msg.variables_ARRAY}`, "Array"],
|
|
||||||
[`${Blockly.Msg.variables_CHARACTER}`, "char"],
|
[`${Blockly.Msg.variables_CHARACTER}`, "char"],
|
||||||
[`${Blockly.Msg.variables_BOOLEAN}`, "boolean"],
|
[`${Blockly.Msg.variables_BOOLEAN}`, "boolean"],
|
||||||
[`${Blockly.Msg.variables_NULL}`, "void"],
|
|
||||||
[`${Blockly.Msg.variables_UNDEF}`, "undefined"],
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
typedVarModal.init();
|
typedVarModal.init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user