Include Script Files (UI.Include)

The UI.Include() method allows you to include and execute code from external .cs files within your Launchpad scripts. This enables reuse code and organize your scripts more easily.

Methods

Use the following methods to include a script file (.cs) inside another script file.

UI.Include(filename)

Includes and executes a .cs file in the current script context.

Parameters:

  • filename (string): The path to the .cs file to include (relative or absolute)

Example:

UI.Include("Utils.cs");
UI.Include("Constants.cs");

UI.Include(filename1, filename2, ...)

Includes multiple .cs files in sequence.

Parameters:

  • filenames (params string[]): Array of filenames to include

Example:

UI.Include("Utils.cs", "Constants.cs", "Helpers.cs");

UI.TryInclude(filename)

Attempts to include a file and returns true if successful, false otherwise.

Parameters:

  • filename (string): The path to the .cs file to include

Returns:

  • bool: True if the file was successfully included, false otherwise

Example:

UI.SetIncludePath(directory)

Sets the default directory where UI.Include() will look for files when using relative paths. This is primarily used in Launchpad Command and Launchpad App where scripts don't have an associated file path.

Parameters:

  • directory (string): The directory path to use as the base for relative includes

Example:

UI.GetIncludePath()

Gets the current default include directory.

Returns:

  • string: The current include path, or null if not set

Example:

Usage

In Launchpad Explorer

When running scripts through Launchpad Explorer, the include system automatically knows the location of your script file. You can use simple relative paths.

In Launchpad Command or App

When typing code directly (not running from a file), you need to either:

  1. Use absolute paths:

  1. Set an include path first:

Last updated