Nucleus handler tools › Docs › Context › PatchFileFindPattern

Context.PatchFileFindPattern

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

Context.PatchFileFindPattern(
  originalFile: string | number | boolean,
  patchedFile: string | number | boolean,
  origPattern: string | number | boolean,
  patchPattern: string | number | boolean,
  patchall: boolean
): boolean
Context.PatchFileFindPattern(
  originalFile: string | number | boolean,
  patchedFile: string | number | boolean,
  origPattern: string | number | boolean,
  insert: number,
  offset: number,
  patchall: boolean
): boolean

Reads originalFile, replaces every occurrence of the hex byte pattern origPattern (spaces allowed) and writes the result to patchedFile, even if nothing matched. Two forms: (originalFile, patchedFile, origPattern, patchPattern, patchall) puts the hex patchPattern in place of each match; (originalFile, patchedFile, origPattern, insert, offset, patchall) writes the low two bytes of the number insert (little-endian) into the pattern at one-based byte position offset. Throws if originalFile doesn't exist; returns true. In the first form, patchall false patches only the first byte of each match: pass true.

✎ AI-written, based on Nucleus GenericContext.cs (PatchFileFindPattern, both overloads). Not from the official docs. Is it wrong? Tell us

✎ Parameters: AI-written from the Nucleus source.

Handler API docs

Is this right? Tell us what's wrong
Stuck, or not sure? Ask other handler authors: Discordr/nucleuscoop