From 0f277208b9a08d0e07b51bf0aab97a932176eaab Mon Sep 17 00:00:00 2001 From: Pao Date: Mon, 9 Jan 2023 23:51:51 +0100 Subject: [PATCH] Added a really shitty check to prevent oven spamming --- media/lua/client/TOC_ContextMenus.lua | 68 ++++++++++++++++++--------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/media/lua/client/TOC_ContextMenus.lua b/media/lua/client/TOC_ContextMenus.lua index c94801d..d2341ee 100644 --- a/media/lua/client/TOC_ContextMenus.lua +++ b/media/lua/client/TOC_ContextMenus.lua @@ -21,6 +21,22 @@ local function otherPlayerLocal(_, partName, action, patient) end +local function CheckIfCanBeOperated(modData) + if modData.TOC.RightHand.IsCut and not modData.RightHand.IsOperated + or modData.TOC.RightForeArm.IsCut and not modData.RightForearm.IsOperated + or modData.TOC.RightArm.IsCut and not modData.RightArm.IsOperated + or modData.TOC.LeftHand.IsCut and not modData.LeftHand.IsOperated + or modData.TOC.LeftForearm.IsCut and not modData.LeftForearm.IsOperated + or modData.TOC.LeftArm.IsCut and not modData.LeftArm.IsOperated then + return true + else + return false + end + +end + + + local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects, _) local player = getSpecificPlayer(playerId); local clickedPlayer @@ -32,28 +48,36 @@ local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects, for i=1,square:getObjects():size() do local object2 = square:getObjects():get(i-1); --For the oven operate part - if instanceof(object2, "IsoStove") and (player:HasTrait("Brave") or player:getPerkLevel(Perks.Strength) >= 6) then - if not object2:isMicrowave() and object2:getCurrentTemperature() > 250 then - local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldobjects, nil); - local subMenu = context:getNew(context); - context:addSubMenu(rootMenu, subMenu) - if modData.TOC.RightHand.IsCut and not modData.TOC.RightForearm.IsCut and not modData.TOC.RightHand.IsOperated then - subMenu:addOption(getText('UI_ContextMenu_RightHand'), worldobjects, operateLocal, "RightHand"); - end - if modData.TOC.LeftHand.IsCut and not modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftHand.IsOperated then - subMenu:addOption(getText('UI_ContextMenu_LeftHand'), worldobjects, operateLocal, "LeftHand"); - end - if modData.TOC.RightForearm.IsCut and not modData.TOC.RightArm.IsCut and not modData.TOC.RightForearm.IsOperated then - subMenu:addOption(getText('UI_ContextMenu_RightForearm'), worldobjects, operateLocal, "RightForearm"); - end - if modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftArm.IsCut and not modData.TOC.LeftForearm.IsOperated then - subMenu:addOption(getText('UI_ContextMenu_LeftForearm'), worldobjects, operateLocal, "LeftForearm"); - end - if modData.TOC.RightArm.IsCut and not modData.TOC.RightArm.IsOperated then - subMenu:addOption(getText('UI_ContextMenu_RightArm'), worldobjects, operateLocal, "RightArm"); - end - if modData.TOC.LeftArm.IsCut and not modData.TOC.LeftArm.IsOperated then - subMenu:addOption(getText('UI_ContextMenu_LeftArm'), worldobjects, operateLocal, "LeftArm"); + + + if CheckIfCanBeOperated(modData) then + + + if instanceof(object2, "IsoStove") and (player:HasTrait("Brave") or player:getPerkLevel(Perks.Strength) >= 6) then + if not object2:isMicrowave() and object2:getCurrentTemperature() > 250 then + local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldobjects, nil); + local subMenu = context:getNew(context); + context:addSubMenu(rootMenu, subMenu) + if modData.TOC.RightHand.IsCut and not modData.TOC.RightForearm.IsCut and not modData.TOC.RightHand.IsOperated then + subMenu:addOption(getText('UI_ContextMenu_RightHand'), worldobjects, operateLocal, "RightHand"); + end + if modData.TOC.LeftHand.IsCut and not modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftHand.IsOperated then + subMenu:addOption(getText('UI_ContextMenu_LeftHand'), worldobjects, operateLocal, "LeftHand"); + end + if modData.TOC.RightForearm.IsCut and not modData.TOC.RightArm.IsCut and not modData.TOC.RightForearm.IsOperated then + subMenu:addOption(getText('UI_ContextMenu_RightForearm'), worldobjects, operateLocal, "RightForearm"); + end + if modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftArm.IsCut and not modData.TOC.LeftForearm.IsOperated then + subMenu:addOption(getText('UI_ContextMenu_LeftForearm'), worldobjects, operateLocal, "LeftForearm"); + end + if modData.TOC.RightArm.IsCut and not modData.TOC.RightArm.IsOperated then + subMenu:addOption(getText('UI_ContextMenu_RightArm'), worldobjects, operateLocal, "RightArm"); + end + if modData.TOC.LeftArm.IsCut and not modData.TOC.LeftArm.IsOperated then + subMenu:addOption(getText('UI_ContextMenu_LeftArm'), worldobjects, operateLocal, "LeftArm"); + end + + break -- stop cycling like an idiot end end end