From 0d3b82aee363438045e7d24e060bc9ed6bf20f1c Mon Sep 17 00:00:00 2001 From: ZioPao Date: Tue, 21 Nov 2023 02:10:09 +0100 Subject: [PATCH] Reworked GetAmputationTexturesIndex --- .../client/TOC/Handlers/AmputationHandler.lua | 1 - media/lua/client/TOC/Handlers/ItemsHandler.lua | 16 +++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/media/lua/client/TOC/Handlers/AmputationHandler.lua b/media/lua/client/TOC/Handlers/AmputationHandler.lua index c78a5e4..8eb8484 100644 --- a/media/lua/client/TOC/Handlers/AmputationHandler.lua +++ b/media/lua/client/TOC/Handlers/AmputationHandler.lua @@ -5,7 +5,6 @@ local PlayerHandler = require("TOC/Handlers/PlayerHandler") local StaticData = require("TOC/StaticData") --------------------------- --- TODO Add Bandages, Torniquet, etc. --- Manages an amputation. Will be run on the patient client ---@class AmputationHandler ---@field patientPl IsoPlayer diff --git a/media/lua/client/TOC/Handlers/ItemsHandler.lua b/media/lua/client/TOC/Handlers/ItemsHandler.lua index 6cf68da..b866716 100644 --- a/media/lua/client/TOC/Handlers/ItemsHandler.lua +++ b/media/lua/client/TOC/Handlers/ItemsHandler.lua @@ -19,26 +19,16 @@ ItemsHandler.Player = {} ---@private function ItemsHandler.Player.GetAmputationTexturesIndex(playerObj, isCicatrized) local textureString = playerObj:getHumanVisual():getSkinTexture() - local isHairy = string.find(textureString, "a$") - -- Hairy bodies - if isHairy then - textureString = textureString:sub(1, -2) -- Removes b at the end to make it compatible - end + local isHairy = textureString:sub(-1) == "a" - local matchedIndex = string.match(textureString, "%d$") + local matchedIndex = tonumber(textureString:match("%d$")) or 0 - -- TODO Rework this if isHairy then matchedIndex = matchedIndex + 5 end - if isCicatrized then - if isHairy then - matchedIndex = matchedIndex + 5 -- to use the cicatrized texture on hairy bodies - else - matchedIndex = matchedIndex + 10 -- cicatrized texture only, no hairs - end + matchedIndex = matchedIndex + (isHairy and 5 or 10) -- We add 5 is it's the texture texture, else 10 end return matchedIndex - 1