Navigation
Browse the developer docs

FH2 Mod Platform for .NET

Scripts

Single .cs or .vb files compiled when the game starts: no project or SDK needed.

By Bartholomew Ho (qiangqiang101) · MIT license · v0.12.0 · 15 Nov 2026 · repository · original page

On this page

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.

Copied from the wiki page Scripts at commit 7396a07 · MIT license
MIT License

Copyright (c) 2026 Bartholomew Ho

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.