From adb9750a46546aca77237f11d811179efeec526e Mon Sep 17 00:00:00 2001 From: Pao Date: Sun, 29 Jan 2023 18:56:25 +0100 Subject: [PATCH] Removed Context Menus, only cheat menu stays there --- media/lua/client/TOC_Compatibility.lua | 42 ++++++++++++++++++++---- media/lua/client/TOC_ContextMenus.lua | 44 ++------------------------ media/lua/client/TOC_main.lua | 7 ++-- 3 files changed, 43 insertions(+), 50 deletions(-) diff --git a/media/lua/client/TOC_Compatibility.lua b/media/lua/client/TOC_Compatibility.lua index 0ce760c..962f987 100644 --- a/media/lua/client/TOC_Compatibility.lua +++ b/media/lua/client/TOC_Compatibility.lua @@ -2,13 +2,45 @@ function TocCheckCompatibilityWithOlderVersions(mod_data) -- Gets the old status and turns it into the new. if mod_data.TOC.Limbs == nil then - print("TOC: Limbs is nil, resetting mod_data") + print("TOC: Limbs is nil, setting new mod_data") TocMapOldDataToNew(mod_data) - elseif mod_data.TOC.Limbs.Right_Hand.is_cut == nil then + end + + if mod_data.TOC.Limbs.Right_Hand.is_cut == nil then print("TOC: Something was wrongly initiliazed before. Resetting parameters") TocResetEverything() else - print("TOC: Found compatible data") + print("TOC: Found compatible data, correcting models in case of errors") + + -- TODO check if models are correctly applied + local player = getPlayer() + local player_inv = player:getInventory() + + for _, side in ipairs(TOC_sides) do + for _, limb in ipairs(TOC_limbs) do + local part_name = side .. "_" .. limb + + if mod_data.TOC.Limbs[part_name].is_cut and mod_data.TOC.Limbs[part_name].is_amputation_shown then + local amputated_clothing_name = "TOC.Amputation_" .. part_name + if player_inv:FindAndReturn(amputated_clothing_name) == nil then + local amputation_clothing_item = player:getInventory():AddItem(TocFindAmputatedClothingFromPartName(part_name)) + TocSetCorrectTextureForAmputation(amputation_clothing_item, player) + player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item) + + + end + + end + + + + + end + end + + + + end end @@ -76,6 +108,7 @@ local function TocSetModDataParams(mod_data, backup_old_data, new_names_table, o mod_data.TOC.Limbs[new_name].is_cut = backup_old_data[old_name][is_cut_old_key] if mod_data.TOC.Limbs[new_name].is_cut then + print("TOC: Found old cut limb, reapplying model") local cloth = getPlayer():getInventory():AddItem(TocFindAmputatedClothingFromPartName(new_name)) getPlayer():setWornItem(cloth:getBodyLocation(), cloth) end @@ -87,9 +120,6 @@ local function TocSetModDataParams(mod_data, backup_old_data, new_names_table, o mod_data.TOC.Limbs[new_name].is_cauterized = backup_old_data[old_name][is_cauterized_old_key] mod_data.TOC.Limbs[new_name].is_amputation_shown = backup_old_data[old_name][is_amputation_shown_old_key] mod_data.TOC.Limbs[new_name].cicatrization_time = backup_old_data[old_name][cicatrization_time_old_key] - - - end end diff --git a/media/lua/client/TOC_ContextMenus.lua b/media/lua/client/TOC_ContextMenus.lua index a6efc4a..8f73ddf 100644 --- a/media/lua/client/TOC_ContextMenus.lua +++ b/media/lua/client/TOC_ContextMenus.lua @@ -32,15 +32,12 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test) local root_option = context:addOption("The Only Cure on " .. clicked_player:getUsername()) local root_menu = context:getNew(context) - - local cut_menu = TocContextMenus.CreateNewMenu("Cut", context, root_menu) - local operate_menu = TocContextMenus.CreateNewMenu("Operate", context, root_menu) local cheat_menu = TocContextMenus.CreateCheatMenu(context, root_menu, local_player, clicked_player) context:addSubMenu(root_option, root_menu) - TocContextMenus.FillCutAndOperateMenus(local_player, clicked_player, worldObjects, - cut_menu, operate_menu) + -- TocContextMenus.FillCutAndOperateMenus(local_player, clicked_player, worldObjects, + -- cut_menu, operate_menu) --TocContextMenus.FillCheatMenu(context, cheat_menu) break @@ -100,10 +97,6 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec end end - - - - TocContextMenus.CreateNewMenu = function(name, context, root_menu) local new_option = root_menu:addOption(name) @@ -113,39 +106,6 @@ TocContextMenus.CreateNewMenu = function(name, context, root_menu) return new_menu end - - -TocContextMenus.FillCutAndOperateMenus = function(local_player, clicked_player, world_objects, cut_menu, operate_menu) - for _, v in ipairs(GetBodyParts()) do - if local_player == clicked_player then -- Local player - if CheckIfCanBeCut(v) and TocGetSawInInventory(local_player) ~= nil then - - cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Cut", local_player, local_player) - - elseif CheckIfCanBeOperated(v) and TocGetKitInInventory(local_player) ~= nil then - operate_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Operate", local_player, - local_player) - end - - else -- Another player - -- TODO add way to prevent cutting already cut parts of another player - - if ModData.get("TOC_PLAYER_DATA")[clicked_player:getUsername()] ~= nil then - local anotherPlayerData = ModData.get("TOC_PLAYER_DATA")[clicked_player:getUsername()] - - if CheckIfCanBeCut(v, anotherPlayerData[1]) and TocGetSawInInventory(local_player) then - cut_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Cut", local_player, - clicked_player) - elseif CheckIfCanBeOperated(v, anotherPlayerData[1]) and TocGetKitInInventory(local_player) ~= nil then - operate_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Operate", - local_player, clicked_player) - end - end - end - end -end - - TocContextMenus.CreateCheatMenu = function(context, root_menu, local_player, clicked_player) if local_player:getAccessLevel() == "Admin" or isDebugEnabled() then diff --git a/media/lua/client/TOC_main.lua b/media/lua/client/TOC_main.lua index 73b378d..5970bac 100644 --- a/media/lua/client/TOC_main.lua +++ b/media/lua/client/TOC_main.lua @@ -71,6 +71,9 @@ function TocSetInitData(mod_data, player) Left_LowerArm = {}, Left_UpperArm = {}, }, + + + Accepted_Prosthesis = {} }, @@ -186,7 +189,7 @@ function TocUpdateBaseData(mod_data) mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.3 mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.2 mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1 - mod_data.TOC.Prosthesis["ProstheticKnife"][part_name].prosthesis_factor = 1.5 + --mod_data.TOC.Prosthesis["ProstheticKnife"][part_name].prosthesis_factor = 1.5 elseif limb == "LowerArm" then @@ -197,7 +200,7 @@ function TocUpdateBaseData(mod_data) mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.35 mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.25 mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.15 - mod_data.TOC.Prosthesis["ProstheticKnife"][part_name].prosthesis_factor = 1.6 + --mod_data.TOC.Prosthesis["ProstheticKnife"][part_name].prosthesis_factor = 1.6 elseif limb == "UpperArm" then mod_data.TOC.Limbs[part_name].cicatrization_base_time = 2000