From 3afedacbb3dfb5ef562bf2b243b3c5375781a504 Mon Sep 17 00:00:00 2001 From: Pao Date: Mon, 30 Jan 2023 18:16:02 +0100 Subject: [PATCH] Cleaning --- .vscode/settings.json | 5 ++- media/lua/client/TOC_Checks.lua | 18 ++------ media/lua/client/TOC_ClientOptions.lua | 55 ----------------------- media/lua/client/TOC_Compatibility.lua | 10 ----- media/lua/client/TOC_ContextMenus.lua | 2 + media/lua/client/TOC_Debug.lua | 2 - media/lua/client/TOC_LocalActions.lua | 4 -- media/lua/client/TOC_ModCompatibility.lua | 9 ++-- media/lua/client/TOC_UI.lua | 24 ++-------- media/lua/client/TOC_Visuals.lua | 2 - media/lua/client/TOC_main.lua | 12 ++--- 11 files changed, 23 insertions(+), 120 deletions(-) delete mode 100644 media/lua/client/TOC_ClientOptions.lua diff --git a/.vscode/settings.json b/.vscode/settings.json index 9302fba..d59bef0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -50,6 +50,9 @@ "isForceDropHeavyItem", "isFHModKeyDown", "getPlayerData", - "FHSwapHandsAction" + "FHSwapHandsAction", + "getClassFieldVal", + "SandboxVars", + "getClassField" ] } \ No newline at end of file diff --git a/media/lua/client/TOC_Checks.lua b/media/lua/client/TOC_Checks.lua index 8ca3bba..d13a30c 100644 --- a/media/lua/client/TOC_Checks.lua +++ b/media/lua/client/TOC_Checks.lua @@ -36,14 +36,12 @@ function CheckIfProsthesisCanBeEquipped(part_name) -- check if prosthesis is in the surgeon inventory... we need to get it before end - function CheckIfProsthesisCanBeUnequipped(part_name) -- TODO we should get item here to be sure that we can do this action instead of relying on some later checks return true end - ------------------------------- @@ -51,18 +49,10 @@ end function CheckIfProsthesisAlreadyInstalled(limbs_data, part_name) - local r = "Right" - local l = "Left" - - - if string.find(part_name, r) then - return (limbs_data[r .. "_Hand"].is_prosthesis_equipped or limbs_data[r .. "_LowerArm"].is_prosthesis_equipped) - - elseif string.find(part_name, l) then - return (limbs_data[l .. "_Hand"].is_prosthesis_equipped or limbs_data[l .. "_LowerArm"].is_prosthesis_equipped) + for _, side in ipairs(TOC_sides) do + if string.find(part_name, side) then + return (limbs_data[side .. "_Hand"].is_prosthesis_equipped or limbs_data[side .. "_LowerArm"].is_prosthesis_equipped) + end end - - - end diff --git a/media/lua/client/TOC_ClientOptions.lua b/media/lua/client/TOC_ClientOptions.lua deleted file mode 100644 index a81443a..0000000 --- a/media/lua/client/TOC_ClientOptions.lua +++ /dev/null @@ -1,55 +0,0 @@ --- --Default options. --- local options = { --- roll_up_sleeves_on_amputated_limbs = true, - --- } - ---https://steamcommunity.com/workshop/filedetails/discussion/2169435993/4260919351480715709/#c4260919351482087243 - - --- -- Connecting the options to the menu, so user can change them. --- if ModOptions and ModOptions.getInstance then --- print("TOC: Found ModOptions, loading it") --- local settings = ModOptions:getInstance(options, "Amputation2", "The Only Cure but better") - - - --- -- FIXME this stuff breaks everything, it's a no go for now - - --- settings.names = { --- roll_up_sleeves_on_amputated_limbs = "Roll up jacket sleeves for amputated limbs", --- } - - --- ModOptions:loadFile() --- local roll_up_sleeves = settings:getData("roll_up_sleeves_on_amputated_limbs") - --- print("TOC: Rolling up sleeves => " .. tostring(options.roll_up_sleeves_on_amputated_limbs)) - --- -- Run it now since we're in the menu, presumably --- TocSetSleeves(options.roll_up_sleeves_on_amputated_limbs) - --- function roll_up_sleeves:OnApply(val) --- self:resetLua() --- end - --- local function TocOnResetLua(reason) --- print("TOC: OnResetLua running TocSetSleeves") --- TocSetSleeves(options.roll_up_sleeves_on_amputated_limbs) - --- end --- Events.OnResetLua.Add(TocOnResetLua) --- else --- ------------------- --- -- DEFAULT SETTINGS --- ------------------ --- -- TODO Test this when mod options is not installed --- - --- end - --- --Make a link --- TOC_Options = {} --- TOC_Options = options - diff --git a/media/lua/client/TOC_Compatibility.lua b/media/lua/client/TOC_Compatibility.lua index 62ab30b..8fcea16 100644 --- a/media/lua/client/TOC_Compatibility.lua +++ b/media/lua/client/TOC_Compatibility.lua @@ -30,19 +30,9 @@ function TocCheckCompatibilityWithOlderVersions(mod_data) end end - TocResetClothingItemBodyLocation(player, side, limb) - - - - - end end - - - - end end diff --git a/media/lua/client/TOC_ContextMenus.lua b/media/lua/client/TOC_ContextMenus.lua index 3b71c55..71bbc2a 100644 --- a/media/lua/client/TOC_ContextMenus.lua +++ b/media/lua/client/TOC_ContextMenus.lua @@ -1,3 +1,5 @@ +-- TODO this should be moved + function TryToToResetEverythingOtherPlayer(_, patient, surgeon) sendClientCommand(surgeon, "TOC", "AskToResetEverything", { patient:getOnlineID() }) end diff --git a/media/lua/client/TOC_Debug.lua b/media/lua/client/TOC_Debug.lua index f2ada04..cc15800 100644 --- a/media/lua/client/TOC_Debug.lua +++ b/media/lua/client/TOC_Debug.lua @@ -94,6 +94,4 @@ function TocTestBodyLocations() print(list:get(i -1):getId()) end - - end \ No newline at end of file diff --git a/media/lua/client/TOC_LocalActions.lua b/media/lua/client/TOC_LocalActions.lua index 153841a..8a0ad45 100644 --- a/media/lua/client/TOC_LocalActions.lua +++ b/media/lua/client/TOC_LocalActions.lua @@ -34,10 +34,6 @@ function TocEquipProsthesisLocal(_, player, part_name) end function TocUnequipProsthesisLocal(_, player, part_name) - --local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient) - ISTimedActionQueue.add(ISUninstallProsthesis:new(player, player, part_name)) - --ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, - -- patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) end diff --git a/media/lua/client/TOC_ModCompatibility.lua b/media/lua/client/TOC_ModCompatibility.lua index 50d754c..56418c2 100644 --- a/media/lua/client/TOC_ModCompatibility.lua +++ b/media/lua/client/TOC_ModCompatibility.lua @@ -26,7 +26,7 @@ local function OverrideFancyHandwork() end --ISInventoryPaneContextMenu.transferIfNeeded(self.chr, item) - -- If we already have the item equipped + -- If we already have the item equipped if (primary and primary == item) or (secondary and secondary == item) then ISTimedActionQueue.add(ISUnequipAction:new(self.chr, item, 20)) equip = false @@ -38,7 +38,7 @@ local function OverrideFancyHandwork() if primary and isForceDropHeavyItem(primary) then ISTimedActionQueue.add(ISUnequipAction:new(self.chr, primary, 50)) ----- treat "equip" as if we have something equipped from here down - equip = false + equip = false end if mod then -- If we still have something equipped in secondary, unequip @@ -71,8 +71,6 @@ local function OverrideFancyHandwork() getPlayerData(self.chr:getPlayerNum()).playerInventory:refreshBackpacks() end - - local og_FHSwapHandsAction = FHSwapHandsAction.start function FHSwapHandsAction:start() @@ -105,5 +103,4 @@ local function OverrideFancyHandwork() end - -Events.OnGameStart.Add(OverrideFancyHandwork) \ No newline at end of file +Events.OnGameStart.Add(OverrideFancyHandwork) diff --git a/media/lua/client/TOC_UI.lua b/media/lua/client/TOC_UI.lua index 229eace..1f1576b 100644 --- a/media/lua/client/TOC_UI.lua +++ b/media/lua/client/TOC_UI.lua @@ -144,28 +144,13 @@ local function OnClickTocMainUI(button, args) end local function OnClickTocDescUI(button, args) + -- Gets every arg from main - local patient = desc_ui.patient local surgeon = desc_ui.surgeon - - -- Validate action - if args.option == "Cut" then - TryTocAction(_, desc_ui.part_name, "Cut", surgeon, patient) - elseif args.option == "Operate" then - TryTocAction(_, desc_ui.part_name, "Operate", surgeon, patient) - - elseif args.option == "Equip" then - TryTocAction(_, desc_ui.part_name, "Equip", surgeon, patient) - -- TODO probably completely broken for MP - -- TODO this is really janky - - elseif args.option == "Unequip" then - TryTocAction(_, desc_ui.part_name, "Unequip", surgeon, patient) - - elseif args.option == "Nothing" then - print("Just do nothing") -- TODO workaround + if args.option ~= "Nothing" then + TryTocAction(_, desc_ui.part_name, args.option, surgeon, patient) end main_ui:close() @@ -354,9 +339,6 @@ end -- Setup stuff with variables and shit function SetupTocMainUI(surgeon, patient, limbs_data) - - -- TODO add a ontick to update it regularly - main_ui.surgeon = surgeon -- we shouldn't need an arg for this main_ui.patient = patient diff --git a/media/lua/client/TOC_Visuals.lua b/media/lua/client/TOC_Visuals.lua index ebb589f..2bbfe51 100644 --- a/media/lua/client/TOC_Visuals.lua +++ b/media/lua/client/TOC_Visuals.lua @@ -1,5 +1,3 @@ --- 6 skin tones or 5? - function TocSetCorrectTextureForAmputation(item, player) local human_visual = player:getHumanVisual() local texture_string = human_visual:getSkinTexture() diff --git a/media/lua/client/TOC_main.lua b/media/lua/client/TOC_main.lua index 8d5f314..3718b36 100644 --- a/media/lua/client/TOC_main.lua +++ b/media/lua/client/TOC_main.lua @@ -71,7 +71,7 @@ function TocSetInitData(mod_data, player) Left_LowerArm = {}, Left_UpperArm = {}, }, - + Accepted_Prosthesis = {} @@ -116,7 +116,7 @@ function TocSetInitData(mod_data, player) mod_data.TOC.Limbs[part_name].is_prosthesis_equipped = false - mod_data.TOC.Limbs[part_name].equipped_prosthesis = {} -- TODO i'm still not usign this, I should though + mod_data.TOC.Limbs[part_name].equipped_prosthesis = {} -- TODO i'm still not usign this, I should though -- Even if there are some duplicates, this is just easier in the end since we're gonna get fairly easily part_name @@ -299,7 +299,8 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille -- If bandages are available, use them - adiacent_body_part:setBandaged(bandage_table.use_bandage, 10, bandage_table.is_bandage_sterilized, bandage_table.bandage_type) + adiacent_body_part:setBandaged(bandage_table.use_bandage, 10, bandage_table.is_bandage_sterilized, + bandage_table.bandage_type) @@ -321,7 +322,8 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille limbs_data[depended_v].cicatrization_time = limbs_data[part_name].cicatrization_base_time - surgeon_factor * 50 - local should_depended_v_be_healed_of_bite = limbs_data[depended_v].is_infected and body_damage:getInfectionLevel() < 20 + local should_depended_v_be_healed_of_bite = limbs_data[depended_v].is_infected and + body_damage:getInfectionLevel() < 20 local depended_body_part = body_damage:getBodyPart(TocGetBodyPartFromPartName(depended_v)) TocSetParametersForMissingLimb(depended_body_part, should_depended_v_be_healed_of_bite) @@ -331,7 +333,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille end - end + end -- Heal the infection here