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.
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
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).
Tell us what's wrongGive feedback
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).
Tell us what's wrongGive feedback