Added a really shitty check to prevent oven spamming

This commit is contained in:
Pao
2023-01-09 23:51:51 +01:00
parent 49b3c5563a
commit 0f277208b9

View File

@@ -21,6 +21,22 @@ local function otherPlayerLocal(_, partName, action, patient)
end 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 function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects, _)
local player = getSpecificPlayer(playerId); local player = getSpecificPlayer(playerId);
local clickedPlayer local clickedPlayer
@@ -32,28 +48,36 @@ local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects,
for i=1,square:getObjects():size() do for i=1,square:getObjects():size() do
local object2 = square:getObjects():get(i-1); local object2 = square:getObjects():get(i-1);
--For the oven operate part --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); if CheckIfCanBeOperated(modData) then
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 if instanceof(object2, "IsoStove") and (player:HasTrait("Brave") or player:getPerkLevel(Perks.Strength) >= 6) then
subMenu:addOption(getText('UI_ContextMenu_RightHand'), worldobjects, operateLocal, "RightHand"); if not object2:isMicrowave() and object2:getCurrentTemperature() > 250 then
end local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldobjects, nil);
if modData.TOC.LeftHand.IsCut and not modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftHand.IsOperated then local subMenu = context:getNew(context);
subMenu:addOption(getText('UI_ContextMenu_LeftHand'), worldobjects, operateLocal, "LeftHand"); context:addSubMenu(rootMenu, subMenu)
end if modData.TOC.RightHand.IsCut and not modData.TOC.RightForearm.IsCut and not modData.TOC.RightHand.IsOperated then
if modData.TOC.RightForearm.IsCut and not modData.TOC.RightArm.IsCut and not modData.TOC.RightForearm.IsOperated then subMenu:addOption(getText('UI_ContextMenu_RightHand'), worldobjects, operateLocal, "RightHand");
subMenu:addOption(getText('UI_ContextMenu_RightForearm'), worldobjects, operateLocal, "RightForearm"); end
end if modData.TOC.LeftHand.IsCut and not modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftHand.IsOperated then
if modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftArm.IsCut and not modData.TOC.LeftForearm.IsOperated then subMenu:addOption(getText('UI_ContextMenu_LeftHand'), worldobjects, operateLocal, "LeftHand");
subMenu:addOption(getText('UI_ContextMenu_LeftForearm'), worldobjects, operateLocal, "LeftForearm"); end
end if modData.TOC.RightForearm.IsCut and not modData.TOC.RightArm.IsCut and not modData.TOC.RightForearm.IsOperated then
if modData.TOC.RightArm.IsCut and not modData.TOC.RightArm.IsOperated then subMenu:addOption(getText('UI_ContextMenu_RightForearm'), worldobjects, operateLocal, "RightForearm");
subMenu:addOption(getText('UI_ContextMenu_RightArm'), worldobjects, operateLocal, "RightArm"); end
end if modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftArm.IsCut and not modData.TOC.LeftForearm.IsOperated then
if modData.TOC.LeftArm.IsCut and not modData.TOC.LeftArm.IsOperated then subMenu:addOption(getText('UI_ContextMenu_LeftForearm'), worldobjects, operateLocal, "LeftForearm");
subMenu:addOption(getText('UI_ContextMenu_LeftArm'), worldobjects, operateLocal, "LeftArm"); 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 end
end end