Has anyone else thought of, or attempted to use NR as a visual code generator for an external language?
In my case of interest that would be Lua. However the application for this I have in mind might work if Node-RED could produce Typescript as there is a transpilation layer made available.
The inspiration for this is first, having completed a project with NR and been inspired by the possibilities, and second watching my kids learn to 'code' with Scratch.
Incidentally, my searches brought me right back here when I found this really fun and clever hack to break open Scratch and connect it to node:
Maybe there's even something possible that could recruit / hijack Scratch into this plan for its UI/codegen.
Separate but related concern, is Node-RED going to hit blockers as a code gen tool? Scratch has been designed to create code and might be the minimum level of similarity to code, but what I see in NR is the possibility at least to craft one or two page scripts where everything is neatly packaged into functions.
Note that the node-red-contrib-blockly node only generates Javascript code, which is then executed in a NodeJs vm (identical to the function-node). There is no way to generate other languages with it, like you can do with standard Blockly. I only developed the blockly node, to allow people (with less Javascript knowledge) to develop their own custom functions, and execute the generated Javascript code automatically.
Oops, deleted my post by mistake. Nevermind it was a load of waffle but did help me think about things a bit. TLDR, I'm going to experiment with your excellent solution @BartButenaers.
It may be possible to transpile from JS to Lua quite reliably, but first I'm going to need to look at how to add library modules to node-red-contrib-blockly. Happy to get into the code, so we'll see what can be achieved
At the time being I have implelented this issue, to allow people to create their own blocks. And those blocks are added to the toolbar. So I assume you can create your own blocks, which generate code. So I assume you can generate code for another language.
However that is only about code generation. From here on the generated code is injected into the vm. And to be honest I want the code and the config screen of this node as simple as possible. So please discuss your proposals before you start implementing.