One way I am aware of is to utilize the following code snippet in Blockly for JavaScript:
Blockly.JavaScript['my_code'] = function() { ... }
However, I want to include support for another language like JSON. So, I attempted to do so with this code:
Blockly.Json['my_code'] = function() { ... }
Unfortunately, when I tried to retrieve the code using:
Blockly.Json.workspaceToCode(this.workspace)
I encountered an error as workspaceToCode
is not recognized as a function.
My objective is to integrate a new programming language into Blockly.
This newly added language (JSON) will not be visible on the interface but will be utilized to issue commands to robots.
In my attempt to configure JSON in Blockly, I used the following code:
Blockly.Json = new Blockly.Generator('Json');
Blockly.Json['my_code'] = function() { ... }
However, I encountered an error while trying to execute:
Blockly.Json.workspaceToCode(this.workspace)
The error message stated:
Uncaught TypeError: this.init is not a function
at js.ou3v.module.exports.Blockly.Generator.workspaceToCode