Skip to main content

run_script_patch

Function run_script_patch 

Source
pub fn run_script_patch(
    script: &str,
    input: &str,
    rel_key: &str,
    parameters: &[ModParameter],
    configuration: &HashMap<String, Value>,
) -> Result<String, ScriptError>
Expand description

Runs a script patch against the provided input string.

Besides input (the file’s decoded contents) and the configured parameters, the script’s scope is populated with:

  • file_path: rel_key, the game-root-relative, lowercase, forward-slashed path of the file being patched. Stable across every read of the same file, regardless of which rule/redirect ultimately served it – see the rel_key discussion in the resolver docs.
  • timestamp: the current time, in nanoseconds since the Unix epoch, at the moment this script runs. This is not a stable or reproducible value, usable as an ad-hoc PRNG, for example.