From 85619edd61458f88f9be7df32b7904073cf88493 Mon Sep 17 00:00:00 2001 From: Witchy <43689925+WitchyMods@users.noreply.github.com> Date: Tue, 26 Sep 2023 03:54:52 -0400 Subject: [PATCH 1/2] Update config.js Added patching page to side bar --- docs/.vitepress/config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index 2f6c6f9..b5d5e5a 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -89,6 +89,7 @@ export default { { text: 'UI Manager', link: '/hammerstone/ui-manager' }, { text: 'Input Manager', link: '/hammerstone/input-manager' }, { text: 'Save State', link: '/hammerstone/save-state' }, + { text: 'Patching', link: '/hammerstone/patching' }, { text: 'DDAPI', collapsible: true, From 74576bf30d3513635a5ba54b719737ac08c0b0ff Mon Sep 17 00:00:00 2001 From: Witchy <43689925+WitchyMods@users.noreply.github.com> Date: Tue, 26 Sep 2023 04:01:33 -0400 Subject: [PATCH 2/2] Update patching.md --- docs/hammerstone/patching.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/hammerstone/patching.md b/docs/hammerstone/patching.md index f80781b..93800d8 100644 --- a/docs/hammerstone/patching.md +++ b/docs/hammerstone/patching.md @@ -75,7 +75,7 @@ operations = { Table operations are a clean and short way to write edits. By default, all table operations will contain these fields: - `type` The type of operation (see Operation Types below) - `skipOnFail` (optional) If true, Hammerstone will move onto the next operation instead of failing the whole patch if the operation fails -- `condition` (optional) A function which receives the fileContent as a parameter and returns a boolean indicating if this operation should be run or not +- `condition` (optional) A function which receives the fileContent and the context as a parameter and returns a boolean indicating if this operation should be run or not The rest of the fields will depend on the operation `type`. @@ -87,6 +87,13 @@ operations = { } ``` +### Context + +The context contains useful information about the file currently being patched: + +- `path` Path of the module (ex: "common/skills") +- `moduleName` Name of the module (ex: "skills") + ### Operation Types Hammerstone provides the following operation types: @@ -132,6 +139,14 @@ In order to be as powerful as can be, Hammerstone provides many ways to fill in - `chunk table` Used to fill the parameter with the content of a chunk - `chunk` (string) The name of the chunk. Equivalent to the name of the chunk file without the ".lua" extension - `indent` (number) (Optional) Number of times to indent the content of the chunk. 1 indent equals to 4 spaces + +#### Keywords + +All string+ can use `keywords`. They are placeholders for values pertaining to the current file being patched. They correspond to the values of the `context`. + +You use them by putting the name of the context value surrounded by a pound sign (ex: "#PATH#"). + +During the operation, they keywords will be replaced by the value in the `context`. ### nodes In order to better search for the right place in the file to start or stop an edit, Hammerstone provide "nodes". They can be the following: