Skip to content

Content Directives

After importing a module with import, you can access its compiled content inline using @ directives. These are replaced at compile time with values from the module.

All directives reference a module name that must be imported in the same file first.

Inlines the full compiled GML declaration of the named module at the current position.

@content <ExportsName>
script1.scaff
export const my_func_expr = (arg1) => {
show_debug_message(arg1);
}
index.scaff
import { my_func_expr } from "./script1"
@content my_func_expr
index.scaff
import { my_func_expr } from "./script1" // will be removed at compile time
@content my_func_expr
my_func_expr = function(arg1) {
show_debug_message(arg1);
}

If @content is indented, the injected content is re-indented to match.


Inlines just the raw value (right-hand side) of the module, without the declaration. You can also use @:<ExportsName> as a shorthand.

@valueof <ExportsName>
@:<ExportsName>
script1.scaff
export var my_var = 10;
export const hello = "Hello, World!";
index.scaff
import * from "./script1"
show_debug_message($"z = @valueof my_var");
show_debug_message(@:hello);
index.scaff
import * from "./script1" // will be removed at compile time
show_debug_message($"z = @valueof z");
show_debug_message(@:hello);
show_debug_message($"z = 10");
show_debug_message("Hello, World!");

Inlines the export name as a plain string (no quotes added).

@nameof <ExportsName>
script1.scaff
export var my_var = 10;
export const hello = "Hello, World!";
index.scaff
import * from "./script1"
show_debug_message($"z = @nameof my_var, hello = {@nameof hello}");
index.scaff
import * from "./script1" // will be removed at compile time
show_debug_message($"z = @nameof my_var, hello = {@nameof hello}");
show_debug_message($"z = my_var, hello = {hello}");

Inlines the exports type of the module as a double-quoted string.

@typeof <ExportsName>
script1.scaff
export var my_var = 10;
export const hello = "Hello, World!";
index.scaff
import * from "./script1"
show_debug_message($"z = @typeof my_var, hello = {@typeof hello}");
index.scaff
import * from "./script1" // will be removed at compile time
show_debug_message($"z = @typeof my_var, hello = {@typeof hello}");
show_debug_message($"z = "variable", hello = {"constant"});

Possible values: "variable" | "constant" | "function" | "method" | "arrow-fn" | "enum" | "interface" | "type" | "class".


Builds a GML struct literal from an imported interface or type. Unset members will fall back to their default values.

@use <ExportsName> { ... }
script1.scaff
export interface MyStruct {
name,
age: number,
address,
phone,
score?,
is_active?: boolean = true,
}
index.scaff
import * from "./script1"
var my_obj = @use MyStruct {
name: "John",
address: some_variable
}
index.scaff
import * from "./script1" // will be removed at compile time
var my_obj = @use MyStruct {
name: "John",
address: some_variable
}
var my_obj = {
name: "John",
age: 0,
address: some_variable,
score: undefined,
is_active: true
}

interface and type will be compiled as struct literal. Here’s how it works:

  1. Fields with no data type, no default value, and not an optional field (marked with ? flag, like phone above) are omitted.
  2. Extra field(s) that are not in the interface or type are appended at the end.
  3. Output indentation matches the surrounding context.
  4. You can use @use with type and interface only.
  5. If you don’t set a default value for a member, but you set a data type, the default value will be a falsy value:
    • number -> 0
    • string -> ""
    • boolean -> false
    • The example above shows that age is a number, but no default value is set, so it’s compiled to 0.
  6. If a field is optional (?):
    • If you don’t set a any value, it will be compiled to = undefined, as shown with score above. It doesn’t matter if you set a data type or not.
    • If you set a default value, it will be compiled to = <default_value>, as shown with is_active above.

How @valueof and @: behave per module type:

Module TypeOutput
variable | constantRight-hand side value
functionFunction declaration and implementation (as function expression)
enumFull enum declaration
interface | typeRaw shape string (not recommended for @valueof)
classRaw class declaration (not recommended for @valueof)