From 8234abd5e2df35908625c2a53fdb738c8f46c821 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Thu, 17 Apr 2025 11:26:58 +0200 Subject: [PATCH] refactor: changed check for version --- .../lua/client/TOC/TimedActions/IgnoredActions.lua | 8 +++++--- common/media/lua/client/TOC/UI/HealthPanel.lua | 11 +++++------ common/media/lua/shared/TOC/StaticData.lua | 12 +++++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/common/media/lua/client/TOC/TimedActions/IgnoredActions.lua b/common/media/lua/client/TOC/TimedActions/IgnoredActions.lua index c1fd215..5d5e88f 100644 --- a/common/media/lua/client/TOC/TimedActions/IgnoredActions.lua +++ b/common/media/lua/client/TOC/TimedActions/IgnoredActions.lua @@ -122,8 +122,10 @@ function ISDrinkFromBottle:new(character, item, uses) return action end -if luautils.stringStarts(StaticData.GAME_VERSION, "41") then - -- This doesn't exist anymore in B42 + +if StaticData.COMPAT_42 == false then + -- TODO confirm that this doesn't exist anymore in B42 + -- B42 nenen local og_ISFinalizeDealAction_new = ISFinalizeDealAction.new function ISFinalizeDealAction:new(player, otherPlayer, itemsToGive, itemsToReceive, time) local action = og_ISFinalizeDealAction_new(self, player, otherPlayer, itemsToGive, itemsToReceive, time) @@ -131,8 +133,8 @@ if luautils.stringStarts(StaticData.GAME_VERSION, "41") then action.skipTOC = true return action end -end +end local og_ISCampingInfoAction_new = ISCampingInfoAction.new diff --git a/common/media/lua/client/TOC/UI/HealthPanel.lua b/common/media/lua/client/TOC/UI/HealthPanel.lua index 4d10d95..fea0e21 100644 --- a/common/media/lua/client/TOC/UI/HealthPanel.lua +++ b/common/media/lua/client/TOC/UI/HealthPanel.lua @@ -13,14 +13,13 @@ local isReady = false local xMod, yMod -if luautils.stringStarts(StaticData.GAME_VERSION, "41") then - xMod = 0 - yMod = 0 -else - -- For some reason (I didn't investigate), when applying stuff to the health panel - -- there is an un-accounted shift in B42. +if StaticData.COMPAT_42 then + -- B42 For some reason (I didn't investigate), when applying stuff to the health panel there is an un-accounted shift in B42. xMod = 5 yMod = 13 +else + xMod = 0 + yMod = 0 end diff --git a/common/media/lua/shared/TOC/StaticData.lua b/common/media/lua/shared/TOC/StaticData.lua index c1a15f5..833095f 100644 --- a/common/media/lua/shared/TOC/StaticData.lua +++ b/common/media/lua/shared/TOC/StaticData.lua @@ -22,7 +22,8 @@ local StaticData = {} StaticData.MOD_NAME = "TOC" -- Game version, used to correct some stuff instead of relying on versioned folders -StaticData.GAME_VERSION = getGameVersion() + +StaticData.COMPAT_42 = luautils.stringStarts(getGameVersion(), "42") ------------------------- --* Base @@ -281,12 +282,13 @@ StaticData.AMPUTATION_CLOTHING_ITEM_BASE = "TOC.Amputation_" local sawObj local gardenSawObj -if luautils.stringStarts(StaticData.GAME_VERSION, "41") then - sawObj = InventoryItemFactory.CreateItem("Base.Saw") - gardenSawObj = InventoryItemFactory.CreateItem("Base.GardenSaw") -else + +if StaticData.COMPAT_42 then sawObj = instanceItem("Base.Saw") gardenSawObj = instanceItem("Base.GardenSaw") +else + sawObj = InventoryItemFactory.CreateItem("Base.Saw") + gardenSawObj = InventoryItemFactory.CreateItem("Base.GardenSaw") end