Skip to content

Scripts

Bartholomew Ho edited this page Nov 9, 2026 · 1 revision

A script is a single .cs or .vb file. Platform.NET compiles it when the game starts, so you need no project, no SDK and no Visual Studio. It's the quickest way to try something.

Write one

Save this as fh2-mods-dotnet\scripts\RepairButton.vb (create the folders if they're missing):

Public Class RepairButton
    Inherits [Mod]

    Public Overrides ReadOnly Property Info As ModInfo
        Get
            Return New ModInfo("RepairButton", "1.0.0")
        End Get
    End Property

    Protected Overrides Sub OnInit()
        ANNA.Items("Car").Add("Repair", Sub() Player.Car?.Repair())
    End Sub
End Class

Or in C#, as RepairButton.cs:

public class RepairButton : Mod
{
    public override ModInfo Info => new("RepairButton", "1.0.0");

    protected override void OnInit() =>
        ANNA.Items("Car").Add("Repair", () => Player.Car?.Repair());
}

Start the game. That's it.

The rules

  • One file is one mod: a public class that inherits Mod.
  • Already imported for you: System, System.Linq, System.Collections.Generic, System.IO, System.Text, System.Threading, System.Threading.Tasks, System.Numerics, FH2 and FH2ModPlatform.
  • If it doesn't compile, the errors go to platform.log and the console, with the file, line and column. That script doesn't start, and everything else carries on.
  • With auto-reload on (MODS > Installed mods > Platform.NET > Reload .NET mods when rebuilt), saving the file recompiles it and swaps it in.
  • To turn a script off, rename it, to RepairButton.vb.off say.
  • A script and a folder mod can't share a name. The folder wins.

When to make a project instead

Scripts need the .NET 10 runtime, like hosted mods. They can't be built as NativeAOT, and they can't use NuGet packages. When you need either, see Your first mod in C# or Your first mod in VB. The code moves over unchanged; just add the Imports / using lines.

Clone this wiki locally