Changed body location name and implemented fix for compat
This commit is contained in:
@@ -38,6 +38,7 @@ function TocCheckCompatibilityWithOlderVersions(mod_data)
|
||||
end
|
||||
end
|
||||
|
||||
TocReapplyBodyLocation()
|
||||
|
||||
|
||||
|
||||
@@ -155,3 +156,88 @@ function TocMapOldDataToNew(mod_data)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
-- Modified functions for compat reason, used only in one instance
|
||||
--------------------
|
||||
local function TocPartNameToOldBodyLocationProsthesis(name)
|
||||
if name == "Right_Hand" then return "ArmRight_Prot" end
|
||||
if name == "Right_LowerArm" then return "ArmRight_Prot" end
|
||||
if name == "Right_UpperArm" then return "ArmRight_Prot" end
|
||||
if name == "Left_Hand" then return "ArmLeft_Prot" end
|
||||
if name == "Left_LowerArm" then return "ArmLeft_Prot" end
|
||||
if name == "Left_UpperArm" then return "ArmLeft_Prot" end
|
||||
end
|
||||
|
||||
local function TocPartNameToOldBodyLocationAmputation(name)
|
||||
if name == "Right_Hand" then return "ArmRight" end
|
||||
if name == "Right_LowerArm" then return "ArmRight" end
|
||||
if name == "Right_UpperArm" then return "ArmRight" end
|
||||
if name == "Left_Hand" then return "ArmLeft" end
|
||||
if name == "Left_LowerArm" then return "ArmLeft" end
|
||||
if name == "Left_UpperArm" then return "ArmLeft" end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TocFindAmputationInInventory(player, side, limb)
|
||||
local player_inventory = player:getInventory()
|
||||
local item_name = "TOC.Amputation_" .. side .. "_" .. limb
|
||||
local found_item = player_inventory:FindAndReturn(item_name)
|
||||
if found_item then
|
||||
return found_item:getFullType()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function TocFindEquippedProsthesisInInventory(player, side, limb)
|
||||
local player_inventory = player:getInventory()
|
||||
for _, prost in ipairs(GetProsthesisList()) do
|
||||
local item_name = "TOC.Prost_" .. side .. "_" .. limb .. "_" .. prost
|
||||
local found_item = player_inventory:FindAndReturn(item_name)
|
||||
|
||||
if found_item then
|
||||
return found_item:getFullType()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function TocOldFindAmputationOrProsthesisName(part_name, player, choice)
|
||||
|
||||
local player_inventory = player:getInventory()
|
||||
|
||||
for _, side in ipairs(TOC_sides) do
|
||||
for _, limb in ipairs(TOC_limbs) do
|
||||
local item_name
|
||||
local found_item
|
||||
if choice == "Amputation" then
|
||||
item_name = "TOC.Amputation_" .. side .. "_" .. limb
|
||||
end
|
||||
|
||||
if choice == "Prosthesis" then
|
||||
item_name = "TOC.Prost" .. side .. "_" .. limb .. "_MetalHook" -- TODO finish this
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
found_item = player_inventory:FindAndReturn(item_name)
|
||||
|
||||
if found_item then
|
||||
return found_item:getFullType()
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -36,6 +36,98 @@ function TocResetEverything()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function TocReapplyBodyLocation()
|
||||
-- get amputated limbs
|
||||
local player = getPlayer()
|
||||
local player_inventory = player:getInventory()
|
||||
|
||||
for _, side in ipairs(TOC_sides) do
|
||||
for _, limb in ipairs(TOC_limbs) do
|
||||
local amputation_item_name = TocFindAmputationInInventory(player, side, limb)
|
||||
local equipped_prosthesis_item_name = TocFindEquippedProsthesisInInventory(player, side, limb)
|
||||
print(amputation_item_name)
|
||||
print(equipped_prosthesis_item_name)
|
||||
if amputation_item_name ~= nil then
|
||||
|
||||
local amputation_item = player_inventory:FindAndReturn(amputation_item_name)
|
||||
if amputation_item ~= nil then
|
||||
player:removeWornItem(amputation_item)
|
||||
player:getInventory():Remove(amputation_item)
|
||||
amputation_item = player_inventory:AddItem(amputation_item_name)
|
||||
TocSetCorrectTextureForAmputation(amputation_item, player)
|
||||
|
||||
player:setWornItem(amputation_item:getBodyLocation(), amputation_item)
|
||||
end
|
||||
amputation_item = nil -- reset it
|
||||
end
|
||||
|
||||
if equipped_prosthesis_item_name ~= nil then
|
||||
local prosthesis_item = player_inventory:FindAndReturn(equipped_prosthesis_item_name)
|
||||
if prosthesis_item ~= nil then
|
||||
print("Resetting " .. prosthesis_item:getName())
|
||||
player:removeWornItem(prosthesis_item)
|
||||
player:getInventory():Remove(prosthesis_item)
|
||||
prosthesis_item = player_inventory:AddItem(equipped_prosthesis_item_name)
|
||||
player:setWornItem(prosthesis_item:getBodyLocation(), prosthesis_item)
|
||||
|
||||
end
|
||||
prosthesis_item = nil -- reset it
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- for _, v in ipairs(GetBodyParts()) do
|
||||
|
||||
-- local amputation_item_name = TocOldFindAmputationOrProsthesisName(v, player, "Amputation")
|
||||
-- local prosthesis_item_name = TocOldFindAmputationOrProsthesisName(v, player, "Prosthesis")
|
||||
|
||||
-- print(amputation_item_name)
|
||||
-- print(prosthesis_item_name)
|
||||
-- if amputation_item_name ~= nil then
|
||||
|
||||
-- local amputation_item = player_inventory:FindAndReturn(amputation_item_name)
|
||||
-- if amputation_item ~= nil then
|
||||
-- player:removeWornItem(amputation_item)
|
||||
-- player:getInventory():Remove(amputation_item)
|
||||
-- amputation_item = player_inventory:AddItem(amputation_item_name)
|
||||
-- player:setWornItem(amputation_item:getBodyLocation(), amputation_item)
|
||||
-- end
|
||||
-- amputation_item = nil -- reset it
|
||||
-- end
|
||||
-- if prosthesis_item_name ~= nil then
|
||||
-- local prosthesis_item = player_inventory:FindAndReturn(prosthesis_item_name)
|
||||
-- if prosthesis_item ~= nil then
|
||||
-- print("Resetting " .. prosthesis_item:getName())
|
||||
-- player:removeWornItem(prosthesis_item)
|
||||
-- player:getInventory():Remove(prosthesis_item)
|
||||
-- prosthesis_item = player_inventory:AddItem(prosthesis_item_name)
|
||||
-- player:setWornItem(prosthesis_item:getBodyLocation(), prosthesis_item)
|
||||
|
||||
-- end
|
||||
-- prosthesis_item = nil -- reset it
|
||||
-- end
|
||||
|
||||
|
||||
-- end
|
||||
|
||||
-- -- get prosthe
|
||||
|
||||
|
||||
-- -- fix them
|
||||
|
||||
|
||||
-- -- reapply them
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -146,23 +146,21 @@ end
|
||||
-- Unequip Prosthesis
|
||||
|
||||
local function PartNameToBodyLocationProsthesis(name)
|
||||
-- This is still correct but naming sucks
|
||||
if name == "Right_Hand" then return "ArmRight_Prot" end
|
||||
if name == "Right_LowerArm" then return "ArmRight_Prot" end
|
||||
if name == "Right_UpperArm" then return "ArmRight_Prot" end
|
||||
if name == "Left_Hand" then return "ArmLeft_Prot" end
|
||||
if name == "Left_LowerArm" then return "ArmLeft_Prot" end
|
||||
if name == "Left_UpperArm" then return "ArmLeft_Prot" end
|
||||
if name == "Right_Hand" then return "TOC_ArmRightProsthesis" end
|
||||
if name == "Right_LowerArm" then return "TOC_ArmRightProsthesis" end
|
||||
if name == "Right_UpperArm" then return "TOC_ArmRightProsthesis" end
|
||||
if name == "Left_Hand" then return "TOC_ArmLeftProsthesis" end
|
||||
if name == "Left_LowerArm" then return "TOC_ArmLeftProsthesis" end
|
||||
if name == "Left_UpperArm" then return "TOC_ArmLeftProsthesis" end
|
||||
end
|
||||
|
||||
local function PartNameToBodyLocationAmputation(name)
|
||||
-- This is still correct but naming sucks
|
||||
if name == "Right_Hand" then return "ArmRight" end
|
||||
if name == "Right_LowerArm" then return "ArmRight" end
|
||||
if name == "Right_UpperArm" then return "ArmRight" end
|
||||
if name == "Left_Hand" then return "ArmLeft" end
|
||||
if name == "Left_LowerArm" then return "ArmLeft" end
|
||||
if name == "Left_UpperArm" then return "ArmLeft" end
|
||||
if name == "Right_Hand" then return "TOC_ArmRight" end
|
||||
if name == "Right_LowerArm" then return "TOC_ArmRight" end
|
||||
if name == "Right_UpperArm" then return "TOC_ArmRight" end
|
||||
if name == "Left_Hand" then return "TOC_ArmLeft" end
|
||||
if name == "Left_LowerArm" then return "TOC_ArmLeft" end
|
||||
if name == "Left_UpperArm" then return "TOC_ArmLeft" end
|
||||
end
|
||||
|
||||
function TocFindItemInProstBodyLocation(part_name, patient)
|
||||
@@ -189,10 +187,7 @@ function TocFindAmputationOrProsthesisName(part_name, player, choice)
|
||||
|
||||
if item:getBodyLocation() == PartNameToBodyLocationAmputation(part_name) then
|
||||
return item:getFullType()
|
||||
|
||||
end
|
||||
|
||||
|
||||
elseif choice == "Prosthesis" then
|
||||
|
||||
if item:getBodyLocation() == PartNameToBodyLocationProsthesis(part_name) then
|
||||
@@ -203,9 +198,6 @@ function TocFindAmputationOrProsthesisName(part_name, player, choice)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user