Some fixes and a compat function for older versions
This commit is contained in:
@@ -79,13 +79,16 @@ function CheckIfItemIsAmputatedLimb(item)
|
|||||||
local item_full_type = item:getFullType()
|
local item_full_type = item:getFullType()
|
||||||
|
|
||||||
local sides = {"Left", "Right"}
|
local sides = {"Left", "Right"}
|
||||||
local limbs_to_check = {"Hand", "Forearm", "Arm"}
|
local limbs_to_check = {"Hand", "LowerArm", "UpperArm"}
|
||||||
|
|
||||||
local is_amputated_limb = false
|
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
|
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)
|
print(check_name)
|
||||||
if item_full_type == check_name then
|
if item_full_type == check_name then
|
||||||
is_amputated_limb = true
|
is_amputated_limb = true
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
|
|
||||||
local mod_data = player:getModData()
|
local mod_data = player:getModData()
|
||||||
|
|
||||||
|
-- TODO
|
||||||
if mod_data.TOC == nil then
|
if mod_data.TOC == nil then
|
||||||
|
|
||||||
|
|
||||||
print("TOC: Creating mod_data.TOC")
|
print("TOC: Creating mod_data.TOC")
|
||||||
|
|
||||||
mod_data.TOC = {
|
mod_data.TOC = {
|
||||||
@@ -32,9 +34,35 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
is_other_bodypart_infected = false
|
is_other_bodypart_infected = false
|
||||||
},
|
},
|
||||||
Prosthesis = {
|
Prosthesis = {
|
||||||
WoodenHook = {},
|
WoodenHook = {
|
||||||
MetalHook = {},
|
Right_Hand = {},
|
||||||
MetalHand = {}
|
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 = {},
|
Generic = {},
|
||||||
}
|
}
|
||||||
@@ -97,7 +125,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
mod_data.TOC.Limbs[part_name].depends_on = {}
|
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["WoodenHook"][part_name].prosthesis_factor = 1.5
|
||||||
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.3
|
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.3
|
||||||
mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1
|
mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1
|
||||||
@@ -106,7 +134,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
elseif limb == "LowerArm" then
|
elseif limb == "LowerArm" then
|
||||||
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1800
|
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1800
|
||||||
mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand",}
|
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["WoodenHook"][part_name].prosthesis_factor = 1.65
|
||||||
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.45
|
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.45
|
||||||
@@ -114,7 +142,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
elseif limb == "UpperArm" then
|
elseif limb == "UpperArm" then
|
||||||
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 2000
|
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.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
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -146,6 +174,9 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
mod_data.TOC.Left_UpperArm.is_cicatrized = true
|
mod_data.TOC.Left_UpperArm.is_cicatrized = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
TheOnlyCure.CheckCompatibilityWithOlderVersions(mod_data)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -166,7 +197,21 @@ function TheOnlyCure.DeclareTraits()
|
|||||||
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
|
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
|
||||||
end
|
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)
|
function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function ISInstallProsthesis:perform()
|
|||||||
return
|
return
|
||||||
end
|
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)
|
self.cloth = self.character:getInventory():AddItem(prosthesis_name)
|
||||||
|
|
||||||
if self.cloth ~= nil then
|
if self.cloth ~= nil then
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ end
|
|||||||
|
|
||||||
function TocFindCorrectClothingProsthesis(item_name, part_name)
|
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
|
return correct_name
|
||||||
|
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user