This is a babel plugin for compiling javascript code to a DF template There is some special syntax, and it does not work with typescript, as it uses type annotations to specify variable scope.
Example:
function Join(): PlayerEvent {
const exampleVariable: Game = "hello"
}
{
"blocks": [
{
"id": "block",
"block": "event",
"args": {
"items": []
},
"action": "Join"
},
{
"id": "block",
"block": "set_var",
"args": {
"items": [
{
"item": {
"data": {
"name": "exampleVariable",
"scope": "unsaved"
},
"id": "var"
},
"slot": 0
},
{
"item": {
"data": {
"name": "hello"
},
"id": "txt"
},
"slot": 1
}
]
},
"action": "="
}
]
}
If you wish to help, make a new project and run:
git clone https://github.com/Wonkers0/DFJS.git
cd ./DFJS
npm i
npm run transpile
Source code is in the src
directory
If you've never used babel before, I recommend the following websites:
- https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md - The Babel Plugin Docs
- https://astexplorer.net/ - For viewing abstract syntax trees