Adds GML language support to Prettier
npm install prettier-plugin-gml
src="https://cdn.rawgit.com/prettier/prettier-logo/master/images/prettier-icon-light.svg">
height="210"
src="https://cdn.iconscout.com/icon/free/png-512/game-maker-2-569485.png">
var enemy = argument0; var damage = argument1
with(enemy)
{
self.hp-=damage
if(self.hp<=0){instance_destroy(self)}
}
`
$3
`
var enemy = argument0;
var damage = argument1;
with (enemy) {
self.hp -= damage;
if (self.hp <= 0) {
instance_destroy(self);
}
}
`
Beautiful! 🌼
Installation
Install the prequisites, then follow either the global or local install below.
Prerequisites
Node and npm must be installed. They can be installed together from here: https://nodejs.org/
You can then verify that Node and npm have been installed correctly by entering the following commands into any terminal such as Powershell:
`
node -v
npm -v
`
If you see a version number for each of them, success! Otherwise, try uninstalling your current version of Node and reinstall it.
Global Install
This will install Prettier and the Prettier GML plugin globally on your machine, meaning it can be used for all of your projects.
`
npm install -g --save-exact prettier prettier-plugin-gml
`
Local Install
This will install Prettier and the Prettier GML plugin ONLY for a single Game Maker project. Open up a terminal in the directory of your Game Maker project and run the following commands:
`
npm init
npm install --save-dev --save-exact prettier prettier-plugin-gml
`
Usage
⚠️IMPORTANT NOTICE⚠️
This extension is still experimental, please be sure to commit your code into version control or have a backup before using this! There may be uncaught bugs that have the potential to delete code. If using VS Code, this is fixable with an "undo" command after saving.
VS Code
Prettier integrates directly into VS Code! Once you have done the above setup, just install the "Prettier" and "GML Support" VS Code extensions. You may need to enable "editor.formatOnSave" in your VS Code preferences, and now when you save a GML file it should automatically format itself!
WARNING: If you followed the global install, this will cause Prettier to start formatting all files you open with VS Code that are supported with Prettier (such as HTML, JS, and CSS files).
Command Line
To use without VS Code, simply follow the installation above and open up a terminal in the directory of your Game Maker project. Then just run
`
prettier --write .
``