It turns Blockly code into Lua meant for CC:Tweaked.
Goal: To connect a CC:Tweaked computer or turtle to this website via websockets to edit code live.
The first thing that needs to be done is scraping CC:Tweaked to get up to date code.
python ./scripts/cctweaked2json.pyYou can test whether the script works or not via this command:
python ./scripts/cctweaked2json.py -tRun python ./scripts/cctweaked2json.py -c Globals -o src/app/lib/blockly.json to generate and update the Blockly blocks.
CC:Tweaked has a few quirks that need to be worked around, but it's no problem of Lua or CC:Tweaked, it's just the way Blockly works. Lua allows for multiple return values, but Blockly only allows for one. So to get around this, this assumes you want to use all values and puts them into a table.
As you can see turtle.craft creates {turtle.craft()}.
Here's a quirk that was introduced by no fault but my own. I find it more precise and easier to code with since it expects that you need to use the return values of each variable. You can create a dummy variable to get around this.
This does make the Lua harder to read to a degree, but the hope is that the Blockly code is easier to read and understand.
Inspired by ccblockly
Source CC:Tweaked



