More fixes for debug cheats

This commit is contained in:
Pao
2023-01-13 16:36:03 +01:00
parent 06bc050ebc
commit 8429164c72
2 changed files with 54 additions and 15 deletions

View File

@@ -1,3 +1,6 @@
-- TODO rewrite this mess
local function CutLocal(_, patient, surgeon, part_name) local function CutLocal(_, patient, surgeon, part_name)
if IsSawInInventory(surgeon) ~= nil then if IsSawInInventory(surgeon) ~= nil then
ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name)); ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name));
@@ -23,11 +26,7 @@ end
function TryToToResetEverythingOtherPlayer(_, patient, surgeon) function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
sendClientCommand(surgeon, "TOC", "AskToResetEverything", {patient:getOnlineID()}) sendClientCommand(surgeon, "TOC", "AskToResetEverything", {patient:getOnlineID()})
end end
--TODO Make the name more unique --TODO Make the name more unique
@@ -65,11 +64,36 @@ local function CheckIfCanBeOperated(modData)
end end
local function CloseAllMenus(player_index)
local contextMenu = getPlayerContextMenu(player_index)
if contextMenu:isVisible() then
contextMenu:closeAll()
end
end
-- Declare context menus here so we can access them later
function ISWorldObjectContextMenu.OnFillTOCMenu(player, context, worldObjects, test) function ISWorldObjectContextMenu.OnFillTOCMenu(player, context, worldObjects, test)
end
function ISWorldObjectContextMenu.OnFillOperateWithOven(player, context, worldObjects, test)
end
----------------------------------------------------------------------------------------------------------
TocContextMenus = {}
TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
local clickedPlayersTable = {} --todo awful workaround local clickedPlayersTable = {} --todo awful workaround
local clickedPlayer = nil local clickedPlayer = nil
@@ -126,11 +150,21 @@ function ISWorldObjectContextMenu.OnFillTOCMenu(player, context, worldObjects, t
--todo right now it doesnt check for a saw. --todo right now it doesnt check for a saw.
if clickedPlayer == player_obj then if clickedPlayer == player_obj then
if getPlayer():getModData().TOC[v_part].is_cut == false then
cutMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, CutLocal, player_obj, player_obj, v_part) cutMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, CutLocal, player_obj, player_obj, v_part)
elseif getPlayer():getModData().TOC[v_part].is_operated == false then
operateMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, OperateLocal, player_obj, player_obj, v_part) operateMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, OperateLocal, player_obj, player_obj, v_part)
end
else else
--TODO Make it so cut limbs do not appear in the Cut Menu
--if clickedPlayer.getModData().TOC[v_part].is_cut == false then
cutMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, TryActionOnOtherPlayerLocal, v_part, "Cut", player_obj, clickedPlayer) cutMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, TryActionOnOtherPlayerLocal, v_part, "Cut", player_obj, clickedPlayer)
--elseif clickedPlayer.getModData().TOC[v_part].is_operated == false then
operateMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, TryActionOnOtherPlayerLocal, v_part, "Operate", player_obj, clickedPlayer); operateMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, TryActionOnOtherPlayerLocal, v_part, "Operate", player_obj, clickedPlayer);
--end
end end
@@ -150,7 +184,7 @@ function ISWorldObjectContextMenu.OnFillTOCMenu(player, context, worldObjects, t
end end
function ISWorldObjectContextMenu.OnFillOperateWithOven(player, context, worldObjects, test) TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjects, test)
local player_obj = getSpecificPlayer(player) local player_obj = getSpecificPlayer(player)
--local clickedPlayer --local clickedPlayer
local modData = player_obj:getModData() local modData = player_obj:getModData()
@@ -188,14 +222,17 @@ function ISWorldObjectContextMenu.OnFillOperateWithOven(player, context, worldOb
end end
TocContextMenus.DoCut = function(_, patient, surgeon, part_name)
if IsSawInInventory(surgeon) then
ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name));
else
surgeon:Say("I don't have a saw on me")
end
end
Events.OnFillWorldObjectContextMenu.Add(TocContextMenus.CreateOperateWithOvenMenu) -- this is probably too much
Events.OnFillWorldObjectContextMenu.Add(TocContextMenus.CreateMenus)
Events.OnFillWorldObjectContextMenu.Add(ISWorldObjectContextMenu.OnFillOperateWithOven) -- this is probably too much
Events.OnFillWorldObjectContextMenu.Add(ISWorldObjectContextMenu.OnFillTOCMenu)

View File

@@ -11,9 +11,11 @@ function ResetEverything()
local cloth = player:getInventory():FindAndReturn(find_clothName2_TOC(v)) local cloth = player:getInventory():FindAndReturn(find_clothName2_TOC(v))
if cloth ~= nil then if cloth ~= nil then
print("Resetting " .. cloth:getName())
player:removeWornItem(cloth) player:removeWornItem(cloth)
player:getInventory():Remove(cloth:getName()) player:getInventory():Remove(cloth)
end end
cloth = nil -- reset it
end end