Some fixes and a compat function for older versions

This commit is contained in:
Pao
2023-01-18 04:12:44 +01:00
parent 332c130dc1
commit 2a2b6ef978
5 changed files with 60 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
function ResetEverything()
local player = getPlayer()
local mod_data = player:getModData()
local mod_data = player:getModData()
mod_data.TOC = nil
TheOnlyCure.InitTheOnlyCure(_, player)

View File

@@ -79,13 +79,16 @@ function CheckIfItemIsAmputatedLimb(item)
local item_full_type = item:getFullType()
local sides = {"Left", "Right"}
local limbs_to_check = {"Hand", "Forearm", "Arm"}
local limbs_to_check = {"Hand", "LowerArm", "UpperArm"}
local is_amputated_limb = false
for _, part_name in ipairs(limbs_to_check) do
for _, part in ipairs(limbs_to_check) do
for _, side in ipairs(sides) do
local check_name = "TOC.Arm" .. side .. "_no" .. part_name
local part_name = side .. "_" .. part
local check_name = "TOC.Amputation_" .. part_name
print(check_name)
if item_full_type == check_name then
is_amputated_limb = true

View File

@@ -15,8 +15,10 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
local mod_data = player:getModData()
-- TODO
if mod_data.TOC == nil then
print("TOC: Creating mod_data.TOC")
mod_data.TOC = {
@@ -32,9 +34,35 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
is_other_bodypart_infected = false
},
Prosthesis = {
WoodenHook = {},
MetalHook = {},
MetalHand = {}
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 = {},
}
@@ -97,7 +125,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
mod_data.TOC.Limbs[part_name].depends_on = {}
mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_hand
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_hand
mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.5
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.3
mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1
@@ -106,7 +134,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
elseif limb == "LowerArm" then
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1800
mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand",}
mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_lowerarm
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_lowerarm
mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.65
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.45
@@ -114,7 +142,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
elseif limb == "UpperArm" then
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 2000
mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand", side .. "_LowerArm",}
mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_upperarm
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_upperarm
end
end
@@ -146,6 +174,9 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
mod_data.TOC.Left_UpperArm.is_cicatrized = true
end
else
TheOnlyCure.CheckCompatibilityWithOlderVersions(mod_data)
end
end
@@ -166,7 +197,21 @@ function TheOnlyCure.DeclareTraits()
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
end
function TheOnlyCure.CheckCompatibilityWithOlderVersions(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")
ResetEverything()
elseif mod_data.TOC.Limbs.Right_Hand.is_cut == nil then
print("TOC: Couldn't recreate all, some stuff is still nil")
ResetEverything()
else
print("TOC: Found compatible data")
end
end
-----------------------------------------------------------------------
function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkiller_table)

View File

@@ -40,7 +40,7 @@ function ISInstallProsthesis:perform()
return
end
local prosthesis_name =TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name)
local prosthesis_name = TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name)
self.cloth = self.character:getInventory():AddItem(prosthesis_name)
if self.cloth ~= nil then

View File

@@ -156,7 +156,7 @@ end
function TocFindCorrectClothingProsthesis(item_name, part_name)
local correct_name = "TOC." .. item_name .. "_" .. part_name
local correct_name = "TOC.Prost_" .. part_name .. "_" .. item_name
return correct_name
end