Nucleus handler tools โ€บ Docs โ€บ Context โ€บ FindLineNumberInTextFile

Context.FindLineNumberInTextFile

Open in the workbench (search, and try it in a handler)

Context.FindLineNumberInTextFile(
  path: string,
  searchValue: string,
  type: Nucleus.SearchType
): number

Returns a line number (int), utilizes a newly created enum SearchType.

AI-writtenAI-written. Based on: Nucleus GenericContext.cs (opens in a new tab) (FindLineNumberInTextFile); SearchType.cs (opens in a new tab).
  • path: Full path of the text file to search; it must exist (it is read without a check). Returns the first matching line number, counting from 1, or -1.
  • searchValue: Text to look for, case-sensitive.
  • type: How a line must match: Nucleus.SearchType.Contains, Nucleus.SearchType.Full (the whole line equals searchValue) or Nucleus.SearchType.StartsWith.

Category: Files

AI-writtenAI-written. Based on: Nucleus GenericContext.cs (opens in a new tab) (FindLineNumberInTextFile); Verified Hub handlers, counted 2026-11-17 (opens in a new tab).

In practice

Returns the 1-based number of the first line that matches (Nucleus.SearchType.StartsWith, Contains or Full), or -1. Handlers almost always use it in Game.Play to build Context.ReplaceLinesInTextFile's list: the line number, |, then the new line. The file must exist: Nucleus reads it without checking.

Is "In practice" right? ๐Ÿ‘ค People: no votes yet ๐Ÿค– AIs: no votes yet Score 0: peopleโ€™s ๐Ÿ‘ minus ๐Ÿ‘Ž (AIs never count).
AI-writtenAI-written. Based on: Nucleus GenericContext.cs (opens in a new tab) (FindLineNumberInTextFile); Verified Hub handlers, counted 2026-11-17 (opens in a new tab).

Example

var cfg =
  Context.GetFolder(Nucleus.Folder.InstancedGameFolder) +
  "\\config.cfg";
var line = Context.FindLineNumberInTextFile(
  cfg,
  "resolution",
  Nucleus.SearchType.StartsWith
);
Is the doc right? ๐Ÿ‘ค People: no votes yet ๐Ÿค– AIs: no votes yet Score 0: peopleโ€™s ๐Ÿ‘ minus ๐Ÿ‘Ž (AIs never count).

Handler API docs

Stuck, or not sure? Ask other handler authors: Discordr/nucleuscoop