typed variables working partially
This commit is contained in:
@@ -12,6 +12,10 @@ const setVariableFunction = function (defaultValue) {
|
||||
Blockly['Arduino'].ORDER_ATOMIC
|
||||
);
|
||||
|
||||
const allVars = Blockly.getMainWorkspace().getVariableMap().getAllVariables();
|
||||
const myVar = allVars.filter(v => v.name === variableName)[0]
|
||||
|
||||
Blockly.Arduino.setupCode_[''] = myVar.type + " " + myVar.name + ';\n';
|
||||
return variableName + ' = ' + (variableValue || defaultValue) + ';\n';
|
||||
};
|
||||
};
|
||||
@@ -25,14 +29,5 @@ const getVariableFunction = function (block) {
|
||||
return [variableName, Blockly['Arduino'].ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly['Arduino']['variables_set_number'] = setVariableFunction(10);
|
||||
Blockly['Arduino']['variables_set_boolean'] = setVariableFunction('true');
|
||||
Blockly['Arduino']['variables_set_string'] = setVariableFunction('" "');
|
||||
Blockly['Arduino']['variables_set_colour'] = setVariableFunction(
|
||||
`{ 22, 0, 22}`
|
||||
);
|
||||
|
||||
Blockly['Arduino']['variables_get_number'] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_get_boolean'] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_get_string'] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_get_colour'] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_set_dynamic'] = setVariableFunction()
|
||||
Blockly['Arduino']['variables_get_dynamic'] = getVariableFunction;
|
||||
Reference in New Issue
Block a user