Skip to content

Extending Scriptor

Grisgram edited this page Oct 7, 2025 · 3 revisions

Scriptor knows most of the GML commands, many GameMaker enums and constants, but of course, such a list is never complete.

When you create your game you will very likely have some of your own enums in the game code and you might want to make Scriptor understand them as well.

There are four major components that define the language elements, scriptor understands. Each of them can be reached through a macro.

#macro description
SCRIPTOR_GML_COMMANDS This is a list of known gml commands
Native commands like array_push, instance_create, etc
SCRIPTOR_GML_CONSTANTS All the known GameMaker constants
Examples are fa_middle, fa_center, vk_space, etc
SCRIPTOR_GML_COLORS All the GameMaker color constants
Examples are c_white, c_black, etc
SCRIPTOR_GML_ENUMS All the known GML (and raptor) enums
Examples are `WindowState.normal

Extending Scriptor

Each of those macros is a pointer to a static struct which simply holds the entries. You may add new members to these structs and they will immediately work, as long as you follow one single simple rule:

The keys of each struct member must start with gml_

Scriptor uses this prefix when its doing a lookup to find a command or enum value.

Here are some examples from each of the four structs, so you can see how to add your own values:

SCRIPTOR_GML_COMMANDS

"gml_abs"			: abs,
"gml_array_first"	: array_first,
"gml_array_foreach"	: array_foreach,
"gml_array_get"		: array_get,
"gml_array_last"	: array_last,

To add a new gml command that is not yet part of scriptor, just write code like this:

SCRIPTOR_GML_COMMANDS[$ "gml_path_get_length"] = path_get_length;

SCRIPTOR_GML_CONSTANTS

"gml_asset_object"	: asset_object,
"gml_asset_path"	: asset_path,
"gml_asset_room"	: asset_room,
"gml_asset_script"	: asset_script,
"gml_asset_shader"	: asset_shader,

To add a new gml constant that is not yet part of scriptor, just write code like this:

SCRIPTOR_GML_CONSTANTS[$ "gml_some_new_constant"] = some_new_constant;

SCRIPTOR_GML_COLORS

"gml_c_aqua"	: 	c_aqua,
"gml_c_black"	: 	c_black,
"gml_c_blue"	: 	c_blue,
"gml_c_dkgray"	: 	c_dkgray,
"gml_c_fuchsia"	: 	c_fuchsia,

To add a new gml color that is not yet part of scriptor, just write code like this:

SCRIPTOR_GML_COLORS[$ "gml_c_rainbow"] = c_rainbow;

SCRIPTOR_GML_ENUMS

"gml_anchor.none"	: anchor.none,
"gml_anchor.right"	: anchor.right,
"gml_anchor.top"	: anchor.top,
"gml_anchor.left"	: anchor.left,
"gml_anchor.bottom"	: anchor.bottom,

To add a new gml enum that is not yet part of scriptor, just write code like this: (Remember: Each enum value must be added seperately!)

SCRIPTOR_GML_ENUMS[$ "gml_field_direction.none" ]	= field_direction.none;
SCRIPTOR_GML_ENUMS[$ "gml_field_direction.north"]	= field_direction.north;
SCRIPTOR_GML_ENUMS[$ "gml_field_direction.east" ]	= field_direction.east;
SCRIPTOR_GML_ENUMS[$ "gml_field_direction.south"]	= field_direction.south;
SCRIPTOR_GML_ENUMS[$ "gml_field_direction.west" ]	= field_direction.west;
SCRIPTOR_GML_ENUMS[$ "gml_field_direction.nesw" ]	= field_direction.nesw;

Clone this wiki locally