VSML.ModApi 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package VSML.ModApi --version 1.0.0
                    
NuGet\Install-Package VSML.ModApi -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VSML.ModApi" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VSML.ModApi" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="VSML.ModApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VSML.ModApi --version 1.0.0
                    
#r "nuget: VSML.ModApi, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VSML.ModApi@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VSML.ModApi&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=VSML.ModApi&version=1.0.0
                    
Install as a Cake Tool

VSML Mod Contract

This library defines the API that VSML mods have access to.

To make a mod, you should define a class that implements IModInit, which defines properties and callbacks that the loader will call when ready.

Example

public class ChartMod : IModInit
{
    public string ModName => "MyMod";
    public string ModVersion => "1.0.0";

    private ILogger _logger = null!;

    public void SetupMod(IGameEnv gameEnv, IProgressTracker progressTracker, ILogger logger)
    {
        _logger = logger; 
        _logger.Information("Setting up!");
        
        progressTracker.SetCurrentStep("Loading sample mod");
        // do setup
    }
    
    public IEnumerable<string> RegisterDependentFiles()
    {
        // the loader will re-run your patching code if it detects this file has changed
        return ["some_file.txt"];
    }

    public void ApplyPatches(IPatchApplicator applicator)
    {
        _logger.Information("Applying patches!");
        
        // HookFunction usage example
        applicator.HookFunction("read_binary_chart", "MyTestHook", """
function $$hook(filepath, verifySig, modsFlag) {
    debug("HOOKED read_binary_chart: ", filepath, verifySig, modsFlag);
    return $$original(filepath, false, modsFlag);
}""");
    }
}

Mod API

  • Logger is just a Serilog logger instance, that writes to the main loader log file.
  • IPatchApplicator is a helper class to allow you to patch the game. It provides helpers for patching code, but also gives you direct access to the game data object.
  • IGameEnv provides data about the environment the game's running in, e.g. folder paths.
  • ICodePatch represents a low-level GM:S assembly patch.
  • SourcePatch is a wrapper over ICodePatch that compiles given GML code and inserts that instead of you writing assembly. Note: this might not play well with locals, I haven't tested it thoroughly.
  • IAdditionalScript represents a new script to add into the game. This isn't inserted anywhere, you need to use one of the patch types above to call it from somewhere.
  • PatchHelpers is a utility class for common patching operations.
  • IProgressTracker is an interface that allows your mod to update the user on what its doing. You should update this if your mod performs any particularly long tasks. These messages are displayed on the loading dialog, so make sure they're clean and readable.

There is a set of extension methods that allow loading GML code from embedded resources in your mod DLL.

By default, the names of embedded resources is long and contains your mod assembly name, but this can be overridden by setting the LogicalName property. I recommend doing this, since it makes your code simpler.

<ItemGroup>
    
    <EmbeddedResource Include="MyScript.gml" LogicalName="gml_GlobalScript_TestMod_MyScript.gml" />
</ItemGroup>
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 102 5/26/2026
1.0.0 99 5/25/2026