From d39eb0e031827fdd9e10442606567aea468dd31b Mon Sep 17 00:00:00 2001 From: Pao Date: Sun, 22 Jan 2023 20:05:20 +0100 Subject: [PATCH] Fixed Uninstall prost in sp --- media/lua/client/TOC_LocalActions.lua | 14 ++++--- media/lua/client/TOC_UI.lua | 17 +++++---- media/lua/client/TOC_main.lua | 53 +++------------------------ 3 files changed, 24 insertions(+), 60 deletions(-) diff --git a/media/lua/client/TOC_LocalActions.lua b/media/lua/client/TOC_LocalActions.lua index 22fdd80..c1cd5bd 100644 --- a/media/lua/client/TOC_LocalActions.lua +++ b/media/lua/client/TOC_LocalActions.lua @@ -1,3 +1,6 @@ +-- TODO patient and surgeon will always be the same if we're local... dumb cock + + function TocCutLocal(_, patient, surgeon, part_name) if TocGetSawInInventory(surgeon) ~= nil then ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name)); @@ -22,8 +25,6 @@ function TocOperateLocal(_, patient, surgeon, part_name, use_oven) end function TocEquipProsthesisLocal(_, patient, surgeon, part_name) - -- TODO probably completely broken for MP - -- TODO this is really janky local surgeon_inventory = surgeon:getInventory() local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or surgeon_inventory:getItemFromType('TOC.MetalHook') or @@ -36,7 +37,10 @@ function TocEquipProsthesisLocal(_, patient, surgeon, part_name) end function TocUnequipProsthesisLocal(_, patient, part_name) - local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient) - ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, - patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) + --local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient) + + ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, patient, part_name)) + + --ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, + -- patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) end diff --git a/media/lua/client/TOC_UI.lua b/media/lua/client/TOC_UI.lua index cef32bb..0d94884 100644 --- a/media/lua/client/TOC_UI.lua +++ b/media/lua/client/TOC_UI.lua @@ -190,18 +190,19 @@ function OnClickTocConfirmUIMP(button, args) local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or surgeon_inventory:getItemFromType('TOC.MetalHook') or surgeon_inventory:getItemFromType('TOC.WoodenHook') - + if prosthesis_to_equip then - ISTimedActionQueue.add(ISInstallProsthesis:new(player, confirm_ui_mp.patient, prosthesis_to_equip, confirm_ui_mp.partNameAct)) + ISTimedActionQueue.add(ISInstallProsthesis:new(player, confirm_ui_mp.patient, prosthesis_to_equip, + confirm_ui_mp.partNameAct)) else player:Say("I don't have a prosthesis right now") end - + elseif confirm_ui_mp.actionAct == "Unequip" and args.option == "yes" then -- We can't check if the player has a prosthesis right now, we need to do it later - -- TODO should check if player has a prosthesis equipped before doing it + -- TODO should check if player has a prosthesis equipped before doing it -- TODO Player is surgeon, but we don't have a confirm_ui_mp.surgeon... awful awful awful @@ -214,7 +215,7 @@ function OnClickTocConfirmUIMP(button, args) end - + end @@ -352,6 +353,8 @@ end function SetupTocMainUI(surgeon, patient, toc_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 @@ -505,7 +508,7 @@ function SendCommandToConfirmUIMP(action, isBitten, userName, partName) if action ~= "Wait server" then confirm_ui_mp["text4"]:setText("You're gonna " .. - action .. " the " .. getText("UI_ContextMenu_" .. partName) .. " of " .. userName) + action .. " the " .. getText("UI_ContextMenu_" .. partName) .. " of " .. userName) confirm_ui_mp["text2"]:setText("Are you sure?") confirm_ui_mp["text2"]:setColor(1, 0, 0, 0) @@ -565,7 +568,6 @@ function ISNewHealthPanel.onClick_TOC(button) end - function TocWaitForOnlinePlayerData(numberTicks) if MP_other_player_toc_data ~= nil then SetupTocMainUI(TocTempTable.TempSurgeon, TocTempTable.TempPatient, MP_other_player_toc_data) @@ -582,7 +584,6 @@ function TocWaitForOnlinePlayerData(numberTicks) end - function ISHealthPanel:createChildren() ISHealthPanel_createChildren(self) diff --git a/media/lua/client/TOC_main.lua b/media/lua/client/TOC_main.lua index ffaaa57..f6ca7a3 100644 --- a/media/lua/client/TOC_main.lua +++ b/media/lua/client/TOC_main.lua @@ -341,21 +341,20 @@ function TheOnlyCure.OperateLimb(part_name, surgeon_factor, use_oven) player:transmitModData() end - function TheOnlyCure.EquipProsthesis(part_name, prosthesis_base_name) local player = getPlayer() - + local toc_data = player:getModData().TOC local prosthesis_name = TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name) local added_prosthesis = player:getInventory():AddItem(prosthesis_name) if part_name ~= nil then - + if added_prosthesis ~= nil then - toc_data.Limbs[part_name].is_prosthesis_equipped = true -- TODO should we show that the hand has a prost too if it's installed in the forearm? + toc_data.Limbs[part_name].is_prosthesis_equipped = true toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name] - + player:setWornItem(added_prosthesis:getBodyLocation(), added_prosthesis) @@ -368,12 +367,10 @@ function TheOnlyCure.EquipProsthesis(part_name, prosthesis_base_name) end - function TheOnlyCure.UnequipProsthesis(part_name, equipped_prosthesis) local player = getPlayer() - - local toc_data = player:getModData().TOC + local toc_data = player:getModData().TOC -- we've got equipped_prosthesis, so we should be able to get it directly @@ -381,8 +378,6 @@ function TheOnlyCure.UnequipProsthesis(part_name, equipped_prosthesis) local equipped_prosthesis_full_type = equipped_prosthesis:getFullType() - - for _, prost_v in ipairs(GetProsthesisList()) do local prosthesis_name = string.match(equipped_prosthesis_full_type, prost_v) if prosthesis_name then @@ -392,7 +387,6 @@ function TheOnlyCure.UnequipProsthesis(part_name, equipped_prosthesis) player:getInventory():Remove(equipped_prosthesis) player:transmitModData() - -- needed to remove from queue / start next. end end @@ -400,9 +394,6 @@ function TheOnlyCure.UnequipProsthesis(part_name, equipped_prosthesis) end - - - function TryTocAction(_, part_name, action, surgeon, patient) -- TODO add checks so that we don't show these menus if a player has already beeen operated or amputated -- TODO at this point surgeon doesnt do anything. We'll fix this later @@ -415,12 +406,8 @@ function TryTocAction(_, part_name, action, surgeon, patient) elseif action == "Operate" then TocOperateLocal(_, surgeon, surgeon, part_name, false) elseif action == "Equip" then - -- TODO finish this - local item TocEquipProsthesisLocal(_, surgeon, surgeon, part_name) elseif action == "Unequip" then - -- TODO finish this - local item TocUnequipProsthesisLocal(_, surgeon, part_name) end else @@ -441,37 +428,9 @@ function TryTocAction(_, part_name, action, surgeon, patient) elseif action == "Operate" then AskCanOperateLimb(patient, part_name) elseif action == "Equip" then - - --local surgeon_inventory = surgeon:getInventory() - - --local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHook') - --local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or - -- surgeon_inventory:getItemFromType('TOC.MetalHook') or - -- surgeon_inventory:getItemFromType('TOC.WoodenHook') - - - AskCanEquipProsthesis(patient, part_name) - - - - - -- if prosthesis_to_equip then - -- ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, - -- patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) - -- else - -- surgeon:Say("I need a prosthesis") - -- end - - - - --AskCanEquipProsthesis(patient, part_name, item) - elseif action == "Unequip" then AskCanUnequipProsthesis(patient, part_name) - -- local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient) - -- ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, - -- patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) end ui.actionAct = action ui.partNameAct = part_name @@ -479,7 +438,7 @@ function TryTocAction(_, part_name, action, surgeon, patient) SendCommandToConfirmUIMP("Wait server") - + end end