Fixed compat a little, prosthesis still missing
This commit is contained in:
@@ -112,19 +112,19 @@ Commands["CanResetEverything"] = function(arg)
|
|||||||
arg["command"] = "ResponseCanAct"
|
arg["command"] = "ResponseCanAct"
|
||||||
arg["toSend"] = {part_name, "Cut", true}
|
arg["toSend"] = {part_name, "Cut", true}
|
||||||
sendClientCommand("TOC", "SendServer", arg)
|
sendClientCommand("TOC", "SendServer", arg)
|
||||||
--ResetEverything()
|
--TocResetEverything()
|
||||||
end
|
end
|
||||||
|
|
||||||
Commands["ResetEverything"] = function(arg)
|
Commands["ResetEverything"] = function(arg)
|
||||||
local arg = arg["toSend"]
|
local arg = arg["toSend"]
|
||||||
ResetEverything()
|
TocResetEverything()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Cheating stuff
|
-- Cheating stuff
|
||||||
Commands["AcceptResetEverything"] = function(arg)
|
Commands["AcceptResetEverything"] = function(arg)
|
||||||
|
|
||||||
local clicked_player = getPlayerByOnlineID(arg[1]) -- TODO delete this
|
local clicked_player = getPlayerByOnlineID(arg[1]) -- TODO delete this
|
||||||
ResetEverything()
|
TocResetEverything()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
86
media/lua/client/TOC_Compatibility.lua
Normal file
86
media/lua/client/TOC_Compatibility.lua
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
function TocCheckCompatibilityWithOlderVersions(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")
|
||||||
|
TocMapOldDataToNew(mod_data)
|
||||||
|
else
|
||||||
|
print("TOC: Found compatible data")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function TocMapOldDataToNew(mod_data)
|
||||||
|
|
||||||
|
local map_names = {
|
||||||
|
Right_Hand = "RightHand",
|
||||||
|
Right_LowerArm = "RightForearm",
|
||||||
|
Right_UpperArm = "RightArm",
|
||||||
|
|
||||||
|
Left_Hand = "LeftHand",
|
||||||
|
Left_LowerArm = "LeftForearm",
|
||||||
|
Left_UpperArm = "LeftArm"
|
||||||
|
}
|
||||||
|
|
||||||
|
local old_names_table = {"RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"}
|
||||||
|
local new_names_table = {"Right_Hand", "Right_LowerArm", "Right_UpperArm", "Left_Hand", "Left_LowerArm", "Left_UpperArm"}
|
||||||
|
print("TOC: Trying to backup old data")
|
||||||
|
local backup_old_data = mod_data.TOC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- for k, v in pairs(map_names) do
|
||||||
|
-- print("TOC: Looping old names...")
|
||||||
|
-- print(k)
|
||||||
|
-- print(v)
|
||||||
|
-- print(backup_old_data[v].is_cut)
|
||||||
|
-- print("__________________")
|
||||||
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- for _, v in ipairs(map_names) do
|
||||||
|
-- print("TOC: Looping old names...")
|
||||||
|
-- print(k)
|
||||||
|
-- print(v)
|
||||||
|
-- print(backup_old_data[v].is_cut)
|
||||||
|
-- print("__________________")
|
||||||
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TocResetEverything()
|
||||||
|
-- For some reasons pairs does not work here...
|
||||||
|
-- TODO ask why
|
||||||
|
for i=1, #new_names_table do
|
||||||
|
print("TOC: Looping " .. i)
|
||||||
|
print(backup_old_data[old_names_table[i]].is_cut)
|
||||||
|
|
||||||
|
local old_name = old_names_table[i]
|
||||||
|
local new_name = new_names_table[i]
|
||||||
|
|
||||||
|
mod_data.TOC.Limbs[new_name].is_cut = backup_old_data[old_name].is_cut
|
||||||
|
|
||||||
|
if mod_data.TOC.Limbs[new_name].is_cut then
|
||||||
|
local cloth = getPlayer():getInventory():AddItem(TocFindAmputatedClothingFromPartName(new_name))
|
||||||
|
getPlayer():setWornItem(cloth:getBodyLocation(), cloth)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
mod_data.TOC.Limbs[new_name].is_infected = backup_old_data[old_name].is_infected
|
||||||
|
mod_data.TOC.Limbs[new_name].is_operated = backup_old_data[old_name].is_operated
|
||||||
|
mod_data.TOC.Limbs[new_name].is_cicatrized = backup_old_data[old_name].is_cicatrized
|
||||||
|
mod_data.TOC.Limbs[new_name].is_cauterized = backup_old_data[old_name].is_cauterized
|
||||||
|
mod_data.TOC.Limbs[new_name].is_amputation_shown = backup_old_data[old_name].is_amputation_shown
|
||||||
|
|
||||||
|
mod_data.TOC.Limbs[new_name].cicatrization_time = backup_old_data[old_name].cicatrization_time
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
getPlayer():transmitModData()
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
@@ -158,7 +158,7 @@ TocContextMenus.CreateCheatMenu = function(context, root_menu, local_player, cli
|
|||||||
local cheat_menu = TocContextMenus.CreateNewMenu("Cheat", context, root_menu)
|
local cheat_menu = TocContextMenus.CreateNewMenu("Cheat", context, root_menu)
|
||||||
|
|
||||||
if clicked_player == local_player then
|
if clicked_player == local_player then
|
||||||
cheat_menu:addOption("Reset TOC for me", _, ResetEverything)
|
cheat_menu:addOption("Reset TOC for me", _, TocResetEverything)
|
||||||
|
|
||||||
else
|
else
|
||||||
cheat_menu:addOption("Reset TOC for " .. clicked_player:getUsername(), _, TryToToResetEverythingOtherPlayer, clicked_player, local_player)
|
cheat_menu:addOption("Reset TOC for " .. clicked_player:getUsername(), _, TryToToResetEverythingOtherPlayer, clicked_player, local_player)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
function ResetEverything()
|
function TocResetEverything()
|
||||||
|
|
||||||
local player = getPlayer()
|
local player = getPlayer()
|
||||||
local mod_data = player:getModData()
|
local mod_data = player:getModData()
|
||||||
|
|||||||
@@ -17,7 +17,14 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
if mod_data.TOC == nil then
|
if mod_data.TOC == nil then
|
||||||
|
TocSetInitData(mod_data, player)
|
||||||
|
else
|
||||||
|
TocCheckCompatibilityWithOlderVersions(mod_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function TocSetInitData(mod_data, player)
|
||||||
|
|
||||||
print("TOC: Creating mod_data.TOC")
|
print("TOC: Creating mod_data.TOC")
|
||||||
|
|
||||||
@@ -144,7 +151,6 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
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.Accepted_Prosthesis[part_name] = accepted_prosthesis_upperarm
|
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_upperarm
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -174,13 +180,13 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function TheOnlyCure.DeclareTraits()
|
function TheOnlyCure.DeclareTraits()
|
||||||
local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8, getText("UI_trait_Amputee_Hand_desc"), false, false)
|
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)
|
amp1:addXPBoost(Perks.Left_Hand, 4)
|
||||||
@@ -197,21 +203,6 @@ 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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user