Documentation
ModdingTerminal

Overview

In-game terminal console and command-line interface

The nox.terminal module provides an in-game terminal with a command registry that other mods can extend.

Built-in Commands

CommandUsage
helphelp [command]
echoecho text
clearclear
configconfig get|set|has|del [path] [value]
modsmods list|get [id]
set / get / unsetEnvironment variables
curlcurl url

Execution Model

Commands are executed via linear scan — the first ICommand.Execute() that returns true wins. Each command parses its own name from the input and returns false if it doesn't match:

public UniTask<bool> Execute(string input, IContext context) {
    var parts = input.Trim().Split(' ', 2);
    if (!parts[0].Equals("mycmd", StringComparison.OrdinalIgnoreCase))
        return UniTask.FromResult(false);  // Not mine — let next command try

    context.PrintLn("Command handled!");
    context.SetResult(true);               // Store result for $result chaining
    return UniTask.FromResult(true);       // Handled — stop scanning
}

ArgParser

For complex argument parsing, use ArgsParser from Nox.CCK.Utils. Pass the raw input minus the command name:

var args = ArgsParser.Parse(input.Substring(cmdLen));
var name = args.Get("name", "World");       // --name World
var verbose = args.GetBool("verbose");       // --verbose (boolean flag)
var ids = args.GetArray("ids", ',');         // --ids a,b,c
var deps = args.GetDictionary("dep");        // --dep mod=1.0 --dep lib=2.0
var dest = args.Positional.Length > 0
    ? args.Positional[0] : "default";        // first positional arg
FormatExampleResult
--key value--name WorldGet("name") → "World"
--key=value--name=WorldGet("name") → "World"
--flag--verboseGetBool("verbose") → true
--no-flag--no-verboseGetBool("verbose") → false
-k value-n WorldGet("n") → "World"
-k=value-n=WorldGet("n") → "World"
-abcmulti-flagGetBool("a"),b,c → true
--dep k=v,k=vdictionaryGetDictionary("dep")

Short flags are case-sensitive (-n ≠ -N). Long flags are lowercase-normalized. Repeated keys accumulate: --id 1 --id 2 → GetArray("id") → ["1","2"].

IContext

Every command receives an IContext:

context.PrintLn("output");            // Write to terminal
context.SetEnvironment("KEY", val);   // Store variable
context.GetEnvironment<T>("KEY");     // Read variable
context.SetResult(obj);               // Set $result for chaining
context.Clear();                      // Clear output
context.SetTitle("My Page");          // Set terminal title

See Environments for $VAR substitution and command chaining with $result.

On this page