Somne bugfixes

This commit is contained in:
Pao
2023-01-30 11:56:05 +01:00
parent bdaf187dd9
commit 9a49d74368
7 changed files with 90 additions and 221 deletions

View File

@@ -45,25 +45,6 @@ function GetAcceptingProsthesisBodyPartTypes()
end
-- TODO This is just convoluted. Do not use this
function FindTocDataPartNameFromBodyPartType(toc_limbs_data, bodyPartType)
if bodyPartType == BodyPartType.Hand_R then
return toc_limbs_data.Right_Hand
elseif bodyPartType == BodyPartType.ForeArm_R then
return toc_limbs_data.Right_LowerArm
elseif bodyPartType == BodyPartType.UpperArm_R then
return toc_limbs_data.Right_UpperArm
elseif bodyPartType == BodyPartType.Hand_L then
return toc_limbs_data.Left_Hand
elseif bodyPartType == BodyPartType.ForeArm_L then
return toc_limbs_data.Left_LowerArm
elseif bodyPartType == BodyPartType.UpperArm_L then
return toc_limbs_data.Left_UpperArm
else
return nil
end
end
function TocGetPartNameFromBodyPartType(body_part)
if body_part == BodyPartType.Hand_R then
@@ -114,3 +95,28 @@ function TocFindCorrectClothingProsthesis(item_name, part_name)
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 = TocFindCorrectClothingProsthesis(prost, side .."_" .. limb)
local found_item = player_inventory:FindAndReturn(item_name)
if found_item then
return found_item:getFullType()
end
end
end

View File

@@ -27,18 +27,19 @@ function TocCheckCompatibilityWithOlderVersions(mod_data)
TocSetCorrectTextureForAmputation(amputation_clothing_item, player)
player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
end
end
TocResetClothingItemBodyLocation(player, side, limb)
end
end
TocReapplyBodyLocation()
@@ -156,88 +157,3 @@ 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

View File

@@ -30,11 +30,22 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
-- FIXME this is to prevent context menu spamming. Find a better way
clicked_players_table[clicked_player:getUsername()] = true
local root_option = context:addOption("The Only Cure on " .. clicked_player:getUsername())
local root_menu = context:getNew(context)
local cheat_menu = TocContextMenus.CreateCheatMenu(context, root_menu, local_player,
clicked_player)
context:addSubMenu(root_option, root_menu)
if local_player:getAccessLevel() == "Admin" or isDebugEnabled() then
local root_option = context:addOption("The Only Cure Cheats on " .. clicked_player:getUsername())
local root_menu = context:getNew(context)
if clicked_player == local_player then
root_menu:addOption("Reset TOC for me", _, TocResetEverything)
else
root_menu:addOption("Reset TOC for " .. clicked_player:getUsername(), _, TryToToResetEverythingOtherPlayer,
clicked_player, local_player)
end
context:addSubMenu(root_option, root_menu)
end
-- TocContextMenus.FillCutAndOperateMenus(local_player, clicked_player, worldObjects,
-- cut_menu, operate_menu)

View File

@@ -37,97 +37,42 @@ function TocResetEverything()
end
function TocReapplyBodyLocation()
-- get amputated limbs
local player = getPlayer()
-- Set correct body locations for items in inventory
function TocResetClothingItemBodyLocation(player, side, limb)
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
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)
-- 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
prosthesis_item = nil -- reset it
end
end
-----------------------------------------------------------------------

View File

@@ -80,7 +80,7 @@ function ISInventoryPane:onMouseDoubleClick(x, y)
local player_inventory = getPlayerInventory(self.player).inventory
if instanceof(item_to_check, "InventoryItem") then
og_ISInventoryPaneOnMouseDoubleClick(self, x, y)
elseif CheckIfItemIsAmputatedLimb(item_to_check.items[1]) or CheckIfItemIsProsthesis(item_to_check.items[1]) then
elseif CheckIfItemIsAmputatedLimb(item_to_check.items[1]) or CheckIfItemIsInstalledProsthesis(item_to_check.items[1]) then
print("TOC: Can't double click this item")
else
og_ISInventoryPaneOnMouseDoubleClick(self, x, y)
@@ -113,9 +113,11 @@ ISInventoryPaneContextMenu.onInspectClothing = function(playerObj, cloth
-- Inspect menu bypasses getActualItems, so we need to add that workaround here too
local clothing_full_type = clothing:getFullType()
if not string.find(clothing_full_type, "Amputation_") then
if CheckIfItemIsAmputatedLimb(clothing) or CheckIfItemIsInstalledProsthesis(clothing) then
print("TOC: Can't inspect this!")
else
og_ISInventoryPaneContextMenuOnInspectClothing(playerObj, clothing)
end
end