Skip to main content

publicModSDKModAPI

Index

Methods

callOriginal

  • callOriginal<TFunctionName>(functionName, args, context): ReturnType<GetDotedPathType<typeof globalThis, TFunctionName>>
  • Call original function, bypassing any hooks and ignoring any patches applied by ALL mods.


    Parameters

    • functionName: TFunctionName

      Name of function to call. Can contain dots to change methods in objects (e.g. Player.CanChange)

    • args: [...Parameters<GetDotedPathType<typeof globalThis, TFunctionName>>[]]

      Arguments to use for the call

    • optionalcontext: any

      this context to use. Defaults to window. If calling method of object, then set this to the object itself (e.g. functionName = Player.CanChange then context = Player)

    Returns ReturnType<GetDotedPathType<typeof globalThis, TFunctionName>>

getOriginalHash

  • getOriginalHash(functionName): string
  • Get hash of original function in CRC32.

    The hash is computed from source obtained using toString with line endings normalized to LF


    Parameters

    • functionName: string

      Name of function. Can contain dots to change methods in objects (e.g. Player.CanChange)

    Returns string

hookFunction

  • hookFunction<TFunctionName>(functionName, priority, hook): () => void
  • Hook a BC function

    @see

    PatchHook


    Parameters

    • functionName: TFunctionName

      Name of function to hook. Can contain dots to change methods in objects (e.g. Player.CanChange)

    • priority: number

      Number used to determinate order hooks will be called in. Higher number is called first

    • hook: PatchHook<GetDotedPathType<typeof globalThis, TFunctionName>>

      The hook itself to use,

    Returns () => void

    Function that can be called to remove this hook

      • (): void
      • Returns void

patchFunction

  • patchFunction<TFunctionName>(functionName, patches): void
  • Patch a BC function

    This method is DANGEROUS to use and has high potential to conflict with other mods.

    Only use it if what you are trying to accomplish can't be done easily with hookFunction.

    This function tranforms BC function to string, replaces patches as pure text and then evaluates it. If you don't know what this means, please avoid this function.


    Parameters

    • functionName: TFunctionName

      Name of function to patch. Can contain dots to change methods in objects (e.g. Player.CanChange)

    • patches: GetDotedPathType<typeof globalThis, TFunctionName> extends AnyFunction ? Record<string, string> : never

      Object in key: value format, where keys are chunks to replace and values are result.

      Patches from multiple calls are merged; where key matches the older one is replaced. Specifying value of null removes patch with this key.

    Returns void

removePatches

  • removePatches(functionName): void
  • Remove all patches by patchFunction from specified function.


    Parameters

    • functionName: string

      Name of function to patch. Can contain dots to change methods in objects (e.g. Player.CanChange)

    Returns void

unload

  • unload(): void
  • Unload this mod, removing any hooks or patches by it. To continue using SDK another call to registerMod is required


    Returns void