MGS Natlang Structure

Because MGS Natlang is white space agnostic, formatting is flexible.

// all these are equally valid:

scriptName{show dialog{Bob "Hello World!"}}

scriptName {
  show dialog { Bob "Hello World!" }
}

scriptName {
  show dialog {
    Bob
    "Hello World!"
  }
}

Commonly, Natlang syntax involves declarations followed by matching pairs of brackets:

Free form phrases often have a known size, such as actions within a script block (with limited numbers of possible arrangements) or dialog parameters (which always appear in pairs). In such cases, terminating characters or brackets are not used.

…However, due to an increasing desire for complex syntax parsing, terminating or separating characters is being gradually introduced. As of August 2024, this is limited to semicolons (;) being used to mark the end of an action, e.g. save slot 4;

Variables

See: Variables (MGS)

MGS Natlang variables are more strict (and complicated) than the JSON/JavaScript equivalents. For example, in some cases, a bareword string may be required when the JSON version might have accepted any type of JS string.

In all "dictionary" syntax definitions in this documentation, words in parentheses are optional, and words starting with dollar signs are MGS Natlang variables.

Comments

MGS Natlang supports two kinds of comments. Both can appear anywhere in an MGS file and inside any block.

Line comment

testScript {
  wait 1000ms;
  wait 1000ms; // line comment
}

This is the only time that line breaks are syntactic in Natlang. Line comments start with // and end either with a line break or the end of the document.

WARNING

Do not use line comments in a file that is to be referenced by include!()! Such files have their line breaks changed to spaces when copied into the secondary file — this is done so that the secondary file's line numbers can remain intact for error handling. As a result, line comments are never terminated, and whole swaths of code might be lost, which can result in a wide range of baffling encoder errors. (This will be fixed eventually, but is not fixed as of August 2024. Be ye warned!)

Fun fact: the MGS Natlang translator (JSON -> Natlang) will take extraneous properties from actions and the like and turn them into line comments automatically.

Block comment

/*
Block comment:
Everything inside is a comment!
The lexer ignores it all! WHEEE
*/

Anything between a /* and a */ is part of the block comment, allowing you to put line breaks and/or extensive text inside a comment.