From b6fb136098286aa2b74a9c643a49ca76ddde252a Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sun, 24 Mar 2024 23:45:35 +0100 Subject: [PATCH] Compat for FH --- .vscode/tasks.json | 9 +++++++++ media/lua/client/TOC/Compat.lua | 32 ++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1f16323..5ff3b30 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -50,6 +50,15 @@ "problemMatcher": [ "$eslint-stylish" ] + }, + { + "label": "Run Zomboid Test Server 2", + "options": {"statusbar": {"label": "$(run) Zomboid Server (TOC+FH+BH)"}}, + "type": "shell", + "command":"\"${config:zomboid_server_folder}\\StartServer64_nosteam_custom.bat\" TOC_FH_BH", + "problemMatcher": [ + "$eslint-stylish" + ] } ] } \ No newline at end of file diff --git a/media/lua/client/TOC/Compat.lua b/media/lua/client/TOC/Compat.lua index ce3da20..af72154 100644 --- a/media/lua/client/TOC/Compat.lua +++ b/media/lua/client/TOC/Compat.lua @@ -1,14 +1,38 @@ ---* BRUTAL HANDS -- * local function HandleModCompatibility() - if getActivatedMods():contains('BrutalHandwork') then + --* BRUTAL HANDS -- * + --[[ + Brutal hands has a TOC_COMPAT but its check is wrong and uses an old API. + ]] + + local activatedMods = getActivatedMods() + TOC_DEBUG.print("Checking for mods compatibility") + + if activatedMods:contains('BrutalHandwork') then + TOC_DEBUG.print("found BrutalHandwork, activating compat module") BrutalHands = BrutalHands or {} BrutalHands.TOC = require("TOC/API") - - -- Brutal hands has a TOC_COMPAT but its check is wrong and uses an old API. end + if activatedMods:contains('FancyHandwork') then + TOC_DEBUG.print("found FancyHandwork, activating compat module") + + require("TimedActions/FHSwapHandsAction") + local og_FHSwapHandsAction_isValid = FHSwapHandsAction.isValid + function FHSwapHandsAction:isValid() + local tocApi = require("TOC/API") + if tocApi.hasBothHands(self.character) then + return og_FHSwapHandsAction_isValid(self) + else + return false + end + end + + + + end + end Events.OnGameStart.Add(HandleModCompatibility)