Refactoring even more since why not at this point

This commit is contained in:
Pao
2023-02-20 13:00:05 +01:00
parent 9a4572258e
commit 33d4a322a1
8 changed files with 95 additions and 85 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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")

View File

@@ -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

View File

@@ -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,19 +120,30 @@ end
local function TocSetInitData(mod_data, player)
print("TOC: Creating mod_data.TOC")
--------
-- NEW NAMING SCHEME
---- Amputations
-- Amputation_Left_Hand
-- Amputation_Right_UpperArm
---- Prosthesis to equip
-- Prost_Left_Hand_MetalHook
-- Prost_Right_Forearm_WoodenHook
--- 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 = {}
mod_data.TOC = {
Limbs = {
-- Limbs
mod_data.TOC.Limbs = {
Right_Hand = {},
Right_LowerArm = {},
Right_UpperArm = {},
@@ -147,8 +156,11 @@ local function TocSetInitData(mod_data, player)
Right_Foot = {},
is_other_bodypart_infected = false
},
Prosthesis = {
}
-- TODO Move this to the global TOC thing
-- Prosthetics
mod_data.TOC.Prosthesis = {
WoodenHook = {
Right_Hand = {},
Right_LowerArm = {},
@@ -181,32 +193,15 @@ local function TocSetInitData(mod_data, player)
Accepted_Prosthesis = {}
},
Generic = {},
}
--------
-- NEW NAMING SCHEME
---- Amputations
-- Amputation_Left_Hand
-- Amputation_Right_UpperArm
-- TODO Move this to the global TOC thing
-- Generic (future uses)
mod_data.TOC.Generic = {}
---- Prosthesis to equip
-- Prost_Left_Hand_MetalHook
-- Prost_Right_Forearm_WoodenHook
--- Objects
-- Prost_Object_WoddenHook
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)

View File

@@ -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

View File

@@ -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