Skip to content

Library Rangers Lua

Gabriel edited this page Sep 26, 2023 · 3 revisions

Lua

Provides access to the Lua virtual machine used by Sonic Frontiers.

Functions;

  • void InitScriptSequence() - initialises an app::ScriptSequence (this is called automatically when entering a new game mode).
  • long GetState() - returns a pointer to the current Lua state.
  • (string, long) GetCurrentScriptResource() - returns a tuple where the string is the Lua script name and the long is a pointer to its data.
  • string Peek(bool isOutput = true) - peeks the current Lua script (this outputs to the console by default).
  • LineHook CreateLineHook(string in_code, string in_scriptName, string in_pattern, HookBehavior in_behaviour, bool in_isRegex = false, RegexOptions in_regexOptions = default) - hooks the specified Lua script and watches for a string pattern to replace it depending on the behaviour.
  • LineHook CreateLineHook(string in_code, string in_pattern, HookBehavior in_behaviour, bool in_isRegex = false) - hooks all Lua scripts and watches for a string pattern to replace it depending on the behaviour.
  • FunctionHook CreateFunctionHook(string in_code, string in_scriptName, string in_functionName, HookBehavior in_behaviour) - hooks the specified Lua script and adds new code to the specified function.
  • FunctionHook CreateFunctionHook(string in_code, string in_functionName, HookBehavior in_behaviour) - hooks all Lua scripts and adds new code to the specified function.
  • void UninstallHook(Hook in_hook) - uninstalls a LineHook or FunctionHook.
  • string CreateFunctionSignature(string in_functionName, params object[] in_args) - creates a Lua function signature based on the input arguments.
  • string GetPreviousError(long in_pLuaState) - returns a string representing the last error provided by the Lua state.
  • void Script(string in_code, bool in_isRunOnce = false) - executes Lua code.
  • void LoadScript(string in_path, bool in_isRunOnce = false) - executes a Lua script at the specified path.
  • void Call(string in_functionName, params object[] in_args) - calls a Lua function.
  • T Call<T>(string in_functionName, params object[] in_args) - calls a Lua function and returns its value.

Types;

  • Hook - the base class for hook types.
    • Members;
      • string ScriptName - the name of the script being hooked.
      • HookBehavior Behaviour - the behaviour of this hook.
      • uint Hash - the string hash representing a unique identifier for this hook.
  • LineHook
    • Members;
      • string Code - the code to inject.
      • string Pattern - the pattern to search for when injecting.
      • bool IsRegex - determines if the pattern matching uses regular expressions.
      • System.Text.RegularExpressions.RegexOptions RegexOptions - the options used when compiling the regular expression.
    • Functions;
      • string WriteHook(string in_code) - injects the custom code into the input Lua string.
      • string ToString() - returns a friendly string representation of the hook (this is also used for the unique identifier).
  • FunctionHook
    • Members;
      • string Code - the code to inject.
      • string FunctionName - the function to search for when injecting.
    • Functions;
      • string WriteHook(string in_code) - injects the custom code into the input Lua string.
      • string ToString() - returns a friendly string representation of the hook (this is also used for the unique identifier).
Clone this wiki locally