Hello!
The research group that I'm part of and I are struggling with getting the value from a variable.
If we place a variable block inside a value block, as shown in the image, the output is the name of the variable, not its value.
In this case, when we run the code, the output is "number_of_ducks little ducks went out one day", instead of "4 little ducks went out one day".
However, if we place only the variable block, as shown in the image below, the code runs as expected.
In this case, the output is "4", which is what we expect.
The code that we currently have for the value block is:
Blockly.JavaScript['rhyme_little_ducks'] = function(block) {
Blockly.JavaScript.init(workspace);
var value_count = Blockly.JavaScript.valueToCode(block, 'count', Blockly.JavaScript.ORDER_ATOMIC);
var text = block.getFieldValue('TEXT');
return ['\'' + value_count + ' ' + text + '\'', Blockly.JavaScript.ORDER_ATOMIC];
}
Any ideas on how to fix this problem?
Thank you very much!