diff --git a/media/lua/client/ActionsMethods/TOC_CutLimb.lua b/media/lua/client/ActionsMethods/TOC_CutLimb.lua index 9b4494e..3e4c2f9 100644 --- a/media/lua/client/ActionsMethods/TOC_CutLimb.lua +++ b/media/lua/client/ActionsMethods/TOC_CutLimb.lua @@ -55,7 +55,7 @@ local function TocDeleteOtherAmputatedLimbs(side) -- if left hand is cut and we cut left lowerarm, then delete hand - for _, limb in pairs(TOC_limbs) do + for _, limb in pairs(TOC.limb_names) do local part_name = "TOC.Amputation_" .. side .. "_" .. limb local amputated_limb = getPlayer():getInventory():FindAndReturn(part_name) if amputated_limb then diff --git a/media/lua/client/TOC_Checks.lua b/media/lua/client/TOC_Checks.lua index 0d7d51b..f717226 100644 --- a/media/lua/client/TOC_Checks.lua +++ b/media/lua/client/TOC_Checks.lua @@ -91,7 +91,7 @@ end function CheckIfProsthesisAlreadyInstalled(limbs_data, part_name) - for _, side in pairs(TOC_sides) do + for _, side in pairs(TOC.side_names) do if string.find(part_name, side) then return (limbs_data[side .. "_Hand"].is_prosthesis_equipped or limbs_data[side .. "_LowerArm"].is_prosthesis_equipped) end diff --git a/media/lua/client/TOC_Compatibility.lua b/media/lua/client/TOC_Compatibility.lua index 58a04d6..dc28b56 100644 --- a/media/lua/client/TOC_Compatibility.lua +++ b/media/lua/client/TOC_Compatibility.lua @@ -7,8 +7,8 @@ local function TocReapplyAmputationClothingItem(mod_data) local player = getPlayer() local player_inv = player:getInventory() - for _, side in ipairs(TOC_sides) do - for _, limb in ipairs(TOC_limbs) do + for _, side in ipairs(TOC.side_names) do + for _, limb in ipairs(TOC.limb_names) do local part_name = side .. "_" .. limb -- Check this before since we could have changed some stuff about part names before fixing them. Could break things diff --git a/media/lua/client/TOC_Debug.lua b/media/lua/client/TOC_Debug.lua index cebf84d..9f55d93 100644 --- a/media/lua/client/TOC_Debug.lua +++ b/media/lua/client/TOC_Debug.lua @@ -42,12 +42,12 @@ function TocResetEverything() toc_traits:remove("Amputee_UpperArm") - TheOnlyCure.InitTheOnlyCure(_, player) + TOC.Init(_, player) -- Destroy the amputation or prosthesis item - for _, side in pairs(TOC_sides) do - for _, limb in pairs(TOC_limbs) do + for _, side in pairs(TOC.side_names) do + for _, limb in pairs(TOC.limb_names) do local part_name = side .. "_" .. limb local amputation_item_name = TocFindAmputationOrProsthesisName(part_name, player, "Amputation") diff --git a/media/lua/client/TOC_HelperFunctions.lua b/media/lua/client/TOC_HelperFunctions.lua index 6793d07..993fcf3 100644 --- a/media/lua/client/TOC_HelperFunctions.lua +++ b/media/lua/client/TOC_HelperFunctions.lua @@ -74,7 +74,7 @@ end -- Override and mod compat helper function TocPopulateCanBeHeldTable(can_be_held, limbs_data) - for _, side in pairs(TOC_sides) do + for _, side in pairs(TOC.side_names) do can_be_held[side] = true if limbs_data[side .. "_Hand"].is_cut then diff --git a/media/lua/client/TOC_Init.lua b/media/lua/client/TOC_Init.lua index eb43a18..f882f46 100644 --- a/media/lua/client/TOC_Init.lua +++ b/media/lua/client/TOC_Init.lua @@ -3,12 +3,10 @@ ------------------------------------------ ------------- INIT FUNCTIONS ------------- -if not TheOnlyCure then - TheOnlyCure = {} -end +if not TOC then + TOC = {} -TOC_sides = { "Left", "Right" } -TOC_limbs = { "Hand", "LowerArm", "UpperArm", "Foot"} +end local function TocCutLimbForTrait(player, limbs_data, part_name) local amputation_clothing_item = player:getInventory():AddItem("TOC.Amputation_" .. part_name) @@ -66,8 +64,8 @@ local function TocUpdateBaseData(mod_data) local accepted_prosthesis_upperarm = {} -- For future stuff local accepted_prosthesis_foot = {} - for _, side in pairs(TOC_sides) do - for _, limb in pairs(TOC_limbs) do + for _, side in pairs(TOC.side_names) do + for _, limb in pairs(TOC.limb_names) do local part_name = side .. "_" .. limb @@ -122,68 +120,6 @@ end local function TocSetInitData(mod_data, player) print("TOC: Creating mod_data.TOC") - - - -- TODO this is gonna become a mess really fast, i fucked up. - -- TODO Move prosthesis to something more easily accessible - -- TODO Acceptable prosthesis need to be moved to something more accessible - - - - - - mod_data.TOC = { - - Limbs = { - Right_Hand = {}, - Right_LowerArm = {}, - Right_UpperArm = {}, - - Left_Hand = {}, - Left_LowerArm = {}, - Left_UpperArm = {}, - - Left_Foot = {}, - Right_Foot = {}, - - is_other_bodypart_infected = false - }, - Prosthesis = { - WoodenHook = { - Right_Hand = {}, - Right_LowerArm = {}, - Right_UpperArm = {}, - - Left_Hand = {}, - Left_LowerArm = {}, - Left_UpperArm = {}, - }, - MetalHook = { - Right_Hand = {}, - Right_LowerArm = {}, - Right_UpperArm = {}, - - Left_Hand = {}, - Left_LowerArm = {}, - Left_UpperArm = {}, - }, - MetalHand = { - Right_Hand = {}, - Right_LowerArm = {}, - Right_UpperArm = {}, - - Left_Hand = {}, - Left_LowerArm = {}, - Left_UpperArm = {}, - }, - - - - Accepted_Prosthesis = {} - - }, - Generic = {}, - } -------- -- NEW NAMING SCHEME @@ -200,13 +136,72 @@ local function TocSetInitData(mod_data, player) --- Objects -- Prost_Object_WoddenHook + -- TODO this is gonna become a mess really fast, i fucked up. + -- TODO Move prosthesis to something more easily accessible + -- TODO Acceptable prosthesis need to be moved to something more accessible + + mod_data.TOC = {} + + -- Limbs + mod_data.TOC.Limbs = { + Right_Hand = {}, + Right_LowerArm = {}, + Right_UpperArm = {}, + + Left_Hand = {}, + Left_LowerArm = {}, + Left_UpperArm = {}, + + Left_Foot = {}, + Right_Foot = {}, + + is_other_bodypart_infected = false + } + + -- TODO Move this to the global TOC thing + -- Prosthetics + mod_data.TOC.Prosthesis = { + WoodenHook = { + Right_Hand = {}, + Right_LowerArm = {}, + Right_UpperArm = {}, + + Left_Hand = {}, + Left_LowerArm = {}, + Left_UpperArm = {}, + }, + MetalHook = { + Right_Hand = {}, + Right_LowerArm = {}, + Right_UpperArm = {}, + + Left_Hand = {}, + Left_LowerArm = {}, + Left_UpperArm = {}, + }, + MetalHand = { + Right_Hand = {}, + Right_LowerArm = {}, + Right_UpperArm = {}, + + Left_Hand = {}, + Left_LowerArm = {}, + Left_UpperArm = {}, + }, + Accepted_Prosthesis = {} + + } + + -- TODO Move this to the global TOC thing + -- Generic (future uses) + mod_data.TOC.Generic = {} - for _, side in pairs(TOC_sides) do - for _, limb in pairs(TOC_limbs) do + for _, side in pairs(TOC.side_names) do + for _, limb in pairs(TOC.limb_names) do local part_name = side .. "_" .. limb @@ -244,7 +239,7 @@ local function TocSetInitData(mod_data, player) end -function TheOnlyCure.InitTheOnlyCure(_, player) +function TOC.Init(_, player) local mod_data = player:getModData() if mod_data.TOC == nil then @@ -257,7 +252,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player) end -local function TocDeclareTraits() +local function InitializeTraits() local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8, getText("UI_trait_Amputee_Hand_desc"), false, false) amp1:addXPBoost(Perks.Left_Hand, 4) @@ -283,6 +278,21 @@ local function TocDeclareTraits() TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm") end +------------------------------------------------------------------------------------ -Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure) -Events.OnGameBoot.Add(TocDeclareTraits) +-- Rewrite 2 Electirc Bogaloo +local function InitializeTheOnlyCure() + + -- Initializes global lists + TOC.side_names = {"Left", "Right"} + TOC.limb_names = { "Hand", "LowerArm", "UpperArm", "Foot"} + + InitializeTraits() + + + Events.OnCreatePlayer.Add(TOC.Init) +end + + + +Events.OnGameBoot.Add(InitializeTheOnlyCure) diff --git a/media/lua/client/TOC_OverridenFunctions.lua b/media/lua/client/TOC_OverridenFunctions.lua index fa179fe..1437765 100644 --- a/media/lua/client/TOC_OverridenFunctions.lua +++ b/media/lua/client/TOC_OverridenFunctions.lua @@ -197,7 +197,7 @@ function ISWearClothing:isValid() -- TODO Sides local limbs_data = self.character:getModData().TOC.Limbs - for _, side in pairs(TOC_sides) do + for _, side in pairs(TOC.side_names) do if string.find(item_full_type, "Test_Tourniquet_" .. side) then if limbs_data[side .. "_UpperArm"].is_cut then return false diff --git a/media/lua/client/TOC_Update.lua b/media/lua/client/TOC_Update.lua index 977af39..5926180 100644 --- a/media/lua/client/TOC_Update.lua +++ b/media/lua/client/TOC_Update.lua @@ -197,7 +197,7 @@ local function TocUpdateEveryTenMinutes() local part_data = player:getModData().TOC.Limbs --Experience for prosthesis user - for _, side in pairs(TOC_sides) do + for _, side in pairs(TOC.side_names) do if part_data[side .. "_Hand"].is_prosthesis_equipped or part_data[side .. "_LowerArm"].is_prosthesis_equipped then player:getXp():AddXP(Perks[side .. "_Hand"], 4) end