Merge pull request #193 from sensebox/fix-getVariable

fix getVariable
This commit is contained in:
Mario Pesch 2022-10-22 13:57:00 +02:00 committed by GitHub
commit 7cceea84fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,11 +34,22 @@ const setVariableFunction = function (defaultValue) {
}; };
const getVariableFunction = function (block) { const getVariableFunction = function (block) {
const variableName = Blockly["Arduino"].nameDB_.getName( var id = block.getFieldValue("VAR");
block.getFieldValue("VAR"),
Blockly.Variables.NAME_TYPE const variableName = Blockly.Variables.getVariable(
); Blockly.getMainWorkspace(),
var code = variableName; id
).name;
const allVars = Blockly.getMainWorkspace()
.getVariableMap()
.getAllVariables();
const myVar = allVars.filter((v) => v.name === variableName)[0];
// const variableName = Blockly["Arduino"].nameDB_.getName(
// block.getFieldValue("VAR"),
// Blockly.Variables.NAME_TYPE
// );
var code = myVar.name;
return [code, Blockly["Arduino"].ORDER_ATOMIC]; return [code, Blockly["Arduino"].ORDER_ATOMIC];
}; };