Write addons for the mental engine with TypeScript.
Types allow you to write safer code that won't have runtime errors duo to missspelling or using the wrong method name.

It also allows for better integration in your IDE with proper intellisense. Documentation and example codes can directly be added to the type declarations.

Classes are supported by TypeScript out of the box and do not require some magic non-standardized lua code / preprocessor to implement them.

This project uses TypeScriptToLua to generate lua code from TypeScript. The generated lua files together with any other valid asset file (images, audio, etc) will be bundled together to an addon. See build.js for more details.
Download the project and run the setup script which will download the Engine / Sonic Game from the offical website, extract and renames it automatically. Then install the dependencies and you should be able to write your own addons. See the instructions below for more a detailed setup for your OS.
git clone https://github.com/danielfvm/mental-ts
cd mental-ts
./setup.sh
npm install
Not yet tested - setup.ps1 and build.js might now work. If that is the case please download the game manually, extract it and rename the folder to mental (place it in the project's root folder). You also might need to rename the paths inside the package.json>scripts to include the .exe.
git clone https://github.com/danielfvm/mental-ts
cd mental-ts
.\setup.ps1
npm install
Inside the mntconfig.json you can configure your plugin.
{
"output": "./mental/addons/my_addon", // Generated addon destination path + name
"assets": [ "src/", "sounds/", "textures/", "scenes/" ], // Folders that build.js will look for assets
"autorun": [ "./src/index.lua" ] // Scripts that should be run at startup
}See index.ts for an example typescript addon that loads on startup. You can add your textures, audio, font, etc to the src/ folder or alternatively you can create separate folders for a more organized project structure. If you do so make sure to specify the new asset folder in the mntconfig.json!
To start the game with your addon run:
npm run release
If you additionaly want to have the imgui debug window run:
npm run debug