mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-23 01:02:23 +08:00
Redesign Script Patches for Lua (#3612)
* Refactor Script Patches for Lua * Use update_all_patches_for_script instead of update and store script's joaat instead of its string
This commit is contained in:
41
docs/lua/classes/scr_patch.md
Normal file
41
docs/lua/classes/scr_patch.md
Normal file
@ -0,0 +1,41 @@
|
||||
# Class: scr_patch
|
||||
|
||||
Class for patching GTA script functions.
|
||||
|
||||
## Constructors (1)
|
||||
|
||||
### `new(script_name, patch_name, pattern, offset, patch_)`
|
||||
|
||||
Adds a patch for the specified script.
|
||||
|
||||
- **Parameters:**
|
||||
- `script_name` (string): The name of the script.
|
||||
- `patch_name` (string): The name of the patch.
|
||||
- `pattern` (string): The pattern to scan for within the script.
|
||||
- `offset` (integer): The position within the pattern.
|
||||
- `patch_` (table): The bytes to be written into the script's bytecode.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
my_patch = scr_patch:new(script_name, patch_name, pattern, offset, patch_)
|
||||
```
|
||||
|
||||
## Functions (2)
|
||||
|
||||
### `enable()`
|
||||
|
||||
Enables the script patch for the current instance. When a new instance is created, it will be enabled by default.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
scr_patch:enable()
|
||||
```
|
||||
|
||||
### `disable()`
|
||||
|
||||
Disables the script patch for the current instance.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
scr_patch:disable()
|
||||
```
|
@ -102,26 +102,6 @@ script.is_active(script_name)
|
||||
script.execute_as_script(script_name, func)
|
||||
```
|
||||
|
||||
### `add_patch(script_name, name, pattern, offset, _patch)`
|
||||
|
||||
Adds a patch for the specified script.
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.add_patch("fm_content_xmas_truck", "Flickering Fix", "56 ? ? 4F ? ? 40 ? 5D ? ? ? 74", 0, {0x2B, 0x00, 0x00})
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `script_name` (string): The name of the script.
|
||||
- `name` (string): The name of the patch.
|
||||
- `pattern` (string): The pattern to scan for within the script.
|
||||
- `offset` (integer): The position within the pattern.
|
||||
- `_patch` (table): The bytes to be written into the script's bytecode.
|
||||
|
||||
**Example Usage:**
|
||||
```lua
|
||||
script.add_patch(script_name, name, pattern, offset, _patch)
|
||||
```
|
||||
|
||||
### `start_launcher_script(script_name)`
|
||||
|
||||
Tries to start a launcher script. Needs to be called in the fiber pool or a loop.
|
||||
|
Reference in New Issue
Block a user