From 80725cf56d3b510ae829959a79190fd6316a84ec Mon Sep 17 00:00:00 2001 From: Pao Date: Sun, 15 Jan 2023 04:26:56 +0100 Subject: [PATCH] Added missing checks --- media/lua/client/TOC_Checks.lua | 11 ++++++++++- media/lua/client/TOC_ContextMenus.lua | 2 +- media/lua/client/TOC_UI.lua | 14 +++----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/media/lua/client/TOC_Checks.lua b/media/lua/client/TOC_Checks.lua index 6b067b4..8692923 100644 --- a/media/lua/client/TOC_Checks.lua +++ b/media/lua/client/TOC_Checks.lua @@ -5,11 +5,20 @@ if TheOnlyCure == nil then end function CheckIfCanBeCut(part_name) - + -- This is just for MP handling... Not enough to check everything return not getPlayer():getModData().TOC[part_name].is_cut end +function CheckIfProsthesisAlreadyInstalled(toc_data, part_name) + + local r = "Right" + local l = "Left" + + return (string.find(part_name, r) and not (toc_data[r .. "Hand"].is_prosthesis_equipped or toc_data[r .. "Forearm"].is_prosthesis_equipped)) or + (string.find(part_name, l) and not (toc_data[l .. "Hand"].is_prosthesis_equipped or toc_data[l .. "Forearm"].is_prosthesis_equipped)) + +end function CheckIfCanBeOperated(part_name) diff --git a/media/lua/client/TOC_ContextMenus.lua b/media/lua/client/TOC_ContextMenus.lua index 5e04008..2feb9cb 100644 --- a/media/lua/client/TOC_ContextMenus.lua +++ b/media/lua/client/TOC_ContextMenus.lua @@ -236,7 +236,7 @@ TocContextMenus.FillCutAndOperateMenus = function(local_player, clicked_player, if local_player == clicked_player then -- Local player - if CheckIfCanBeCut(v) then + if CheckIfCanBeCut(v) and not CheckIfProsthesisAlreadyInstalled(local_toc_data, v) then cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Cut", local_player, local_player) --cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TocCutLocal, local_player, local_player, v) diff --git a/media/lua/client/TOC_UI.lua b/media/lua/client/TOC_UI.lua index 897d371..e3a7122 100644 --- a/media/lua/client/TOC_UI.lua +++ b/media/lua/client/TOC_UI.lua @@ -99,15 +99,7 @@ local function IsPartBitten(part_data, part_name) return not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)):bitten() end -local function CanLimbBeAmputated(toc_data, part_name) - local r = "Right" - local l = "Left" - - return (string.find(part_name, r) and not (toc_data[r .. "Hand"].is_prosthesis_equipped or toc_data[r .. "Forearm"].is_prosthesis_equipped)) or - (string.find(part_name, l) and not (toc_data[l .. "Hand"].is_prosthesis_equipped or toc_data[l .. "Forearm"].is_prosthesis_equipped)) - -end local function FindMinMax(lv) @@ -444,16 +436,16 @@ function SetupTocDescUI(surgeon, patient, toc_data, part_name) desc_ui["status"]:setText("Nothing here") desc_ui["status"]:setColor(1, 1, 1, 1) desc_ui["b1"]:setVisible(false) - else + elseif CheckIfCanBeCut(part_name) then -- Everything else -- TODO add check for cuts and scratches desc_ui["status"]:setText("Not cut") desc_ui["status"]:setColor(1, 1, 1, 1) - if GetSawInInventory(surgeon) and CanLimbBeAmputated(toc_data, part_name) then + if GetSawInInventory(surgeon) and CheckIfProsthesisAlreadyInstalled(toc_data, part_name) then desc_ui["b1"]:setVisible(true) desc_ui["b1"]:setText("Cut") desc_ui["b1"]:addArg("option", "Cut") - elseif GetSawInInventory(surgeon) and not CanLimbBeAmputated(toc_data, part_name) then + elseif GetSawInInventory(surgeon) and not CheckIfProsthesisAlreadyInstalled(toc_data, part_name) then desc_ui["b1"]:setVisible(true) desc_ui["b1"]:setText("Remove prosthesis before") desc_ui["b1"]:addArg("option", "Nothing")