Code Snippets

A very handy tool you have at your disposal when editing your code is the use of Code Snippets. When using the script editor, you can press F4 to open the code snippet pop-up, which permits you to select one of the commonly used code methods from a list:

Code Snippets WindowFrom this window you can select with the mouse the snippet to use, or you can press the associated hotkey listed on the right. This will add the snippet to your code for editing.

You can also define your own code snippets if you want to. Before doing this, you'll need to create a file called "snippets.txt" in one of the following directories:

This folder is not modified during any update to GameMaker, so your edited file will remain intact (but any edits to the base snippets file in the install directory will be reverted).

Once the file is created in the User directory, you can edit it with any text editor following these rules:

I - Instance Create:

After the colon you add the snippet of code

I - Instance Create:instance_create_layer(x, y, |layer|, object);

The code that you add must also follow a specific format where:

See the examples that are already in the base snippets file to see how it is set up following the rules above. You can find the base file in the GameMaker install directory:

Code Snippets Example