Skip to content
Bartholomew Ho edited this page Nov 15, 2026 · 1 revision

GameDb

The game's database and string lookups while it runs: rewrite the SQL the game sends to gamedb, and answer string keys no string table has. With Mod.AddSql (new rows) and Mod.SetFile (icons), these make a custom upgrade part, as FnFNitro's NOS kit and FH2 Underglow's kit are made.

New in 0.12.0. ⚠️ Not tested in the game yet.

Thread: add and remove from any thread. Your functions run on whichever thread the game asked from, often the game's own.

Example

protected override void OnInit()
{
    // a part of our own, in rows added with AddSql, named through a string key no table has
    GameDb.AddStringAnswer((table, key) => key == 60001 ? "Turbo kit" : null);
    // and a query seen (or changed) as the game runs it: null leaves it as it is
    GameDb.AddQueryRewriter(sql =>
    {
        if (sql.Contains("Profile0_Career_PurchasedParts")) Log(sql);
        return null;
    });
}

Members

Member What it does
AddQueryRewriter(Func<string, string?> rewriter) Gets each SQL statement the game runs on gamedb and gives back the one to run instead, or null to leave it.
RemoveQueryRewriter(Func<string, string?> rewriter) Stops it.
AddStringAnswer(Func<int, int, string?> answer) Gets the table (as the game numbers it while it runs) and the key of a string the game looked up and found nothing for, and gives back the text, or null.
RemoveStringAnswer(Func<int, int, string?> answer) Stops it.

Notes

  • Every query goes through your rewriter, often many a frame in the garage. Keep it fast, and give back null for the ones you leave alone.
  • A string answer is only asked for when the game found nothing, so use keys the game doesn't have.
  • The hooks go in the first time you add one. The database query is found a moment after the game starts; until then statements run as they are.
  • A hosted mod's functions go when it's reloaded.
  • For text the game already has, Mod.SetString edits the string tables instead. For text in every language, see Translations.

See also

Clone this wiki locally