/grandma3-ts

Primary LanguageTypeScriptMIT LicenseMIT

grandMA3 TypeScript Template Plugin

A starting point for your grandMA3 plugin project written in TypeScript.

build on

TypeScriptToLua

as well as:

  • grandMA3-types - TypeScript definitions for the grandMA3 Lua API
  • grandMA3-tstl-plugin - a TypeScriptToLua plugin that allows for direct export to grandMA3 compatible Lua files

prerequisites

download template

To optimize the development process it's recommended to download the plugin template to following <path> for development:

  • Windows: C:/ProgramData/MALightingTechnology/gma3_library/datapools/plugins/my-new-plugin
  • Mac: HD/users/[username]/MALightingTechnology/gma3_library/datapools/plugins/my-new-plugin

This can either be done thru downloading the repos as *.zip and unpacking at said path or directly cloning the repository via cmdline.

git clone https://github.com/LightYourWay/grandMA3-ts-template-plugin.git <path>

install dependencies

Open the <path> in your IDE

code <path>

and install all dependencies with npm in the terminal:

npm install

add metadata

Change package.json to reflect your project.

"name": "my-new-plugin",
"version": "0.0.1",
"description": "A plugin that will change the lighting industry forever.",
"author": "Max Mustermann",
"license": "MIT",
"gma_version": "1.6.3.7",

choose a license

Change src/LICENSE to reflect your desired license as it will be inserted on top of every compiled file to let others know about the conditions which come with using your software. Please use the placeholders [year] and [fullname] for year of creation and author information inside the license file. If you are not sure which licence suits your project best you can get an overview of existing Open Source Software Licenses at choosealicense.com

develop features

Add your features to the plugin entrypoint at plugin.ts

// ****************************************************************
// plugin load entry point
// ****************************************************************
function Load() {
	Echo(`grandma3-tstl-template-plugin has been loaded...`);
}

Load();

// ****************************************************************
// plugin main entry point
// ****************************************************************
function Main(display_handle: number, argument: any) {
	Printf(`grandma3-tstl-template-plugin has been called...`);
	Printf(`MY NEW FEATURE!!!`)
}

// ****************************************************************
// plugin exit cleanup entry point
// ****************************************************************
function Cleanup() {
	Echo(`grandma3-tstl-template-plugin has been cleaning up...`);
}

// ****************************************************************
// plugin execute entry point
// ****************************************************************
function Execute(Type: string, ...args: any[]) {
	Echo(`grandma3-tstl-template-plugin has been executed...`);
}

export = [Main, Cleanup, Execute];

There are four entrypoints to hook functions into:

  • Load is executed when the plugin is imported in the first place
  • Main is executed when the plugin is pressed or Go+ is executed on the plugin
  • Cleanup is currently unknown
  • Execute is currently unknown

compile to lua

development

To build your plugin for development and watch for file changes to automatically recompile run:

npm run watch 

production

To build your plugin for production run:

npm run build 

import into grandMA3

As long as the plugin development folder is located in the said <path> of grandMA3 the plugin can directly be imported like so: How to import the plugin

🎉 you successfully loaded a plugin written in TypeScript into the grandMA3 ✨