Skip to content

UndertaleModTool Scripting

Miepee edited this page Jun 11, 2022 · 4 revisions

UndertaleModTool can be extended with the use of C# Scripts. When writing such scripts, one should be familiar with both C# as a language, as well as having a broad understanding of GameMaker.

Scripts can be used for a variety of things such as:

  • automate tedious tasks
  • having an open patch format for mods
  • do other modifications to a GameMaker game

TODO: this needs to be done.
Currently, the API is not documented somewhere publically and is only observable via in-code documentation.

Examples

In general, all of the bundled UMT scripts located under the Scripts directory can be used as examples.

Lint and Run other Scripts

string pathToScript = "./MyScriptFile.csx";
// Only Lints the script and determines whether it's valid code
bool lintSuccecssful = LintUMTScript(pathToScript);
// Runs the script. This can be called independently from linting
bool runSuccessful = RunUMTScript(pathToScript);

ScriptMessage("Script was linted successfully: " +  lintSuccecssful);
ScriptMessage("Script was run successfully: " +  runSuccessful);
if (!runSuccessful)
    // ScriptErrorType and ScriptErrorMessage contain the type and message of the last encountered error. 
    // Both will be empty by default.
    ScriptMessage("Script error type: " + ScriptErrorType + " , script error message: " + ScriptErrorMessage);

TODO: add more examples.