JiningLiu / DFJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Javascript to DF compiler

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:

About


Languages

Language:TypeScript 100.0%