Added missing checks
This commit is contained in:
@@ -5,11 +5,20 @@ if TheOnlyCure == nil then
|
|||||||
end
|
end
|
||||||
|
|
||||||
function CheckIfCanBeCut(part_name)
|
function CheckIfCanBeCut(part_name)
|
||||||
|
-- This is just for MP handling... Not enough to check everything
|
||||||
return not getPlayer():getModData().TOC[part_name].is_cut
|
return not getPlayer():getModData().TOC[part_name].is_cut
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function CheckIfProsthesisAlreadyInstalled(toc_data, part_name)
|
||||||
|
|
||||||
|
local r = "Right"
|
||||||
|
local l = "Left"
|
||||||
|
|
||||||
|
return (string.find(part_name, r) and not (toc_data[r .. "Hand"].is_prosthesis_equipped or toc_data[r .. "Forearm"].is_prosthesis_equipped)) or
|
||||||
|
(string.find(part_name, l) and not (toc_data[l .. "Hand"].is_prosthesis_equipped or toc_data[l .. "Forearm"].is_prosthesis_equipped))
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function CheckIfCanBeOperated(part_name)
|
function CheckIfCanBeOperated(part_name)
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ TocContextMenus.FillCutAndOperateMenus = function(local_player, clicked_player,
|
|||||||
|
|
||||||
|
|
||||||
if local_player == clicked_player then -- Local player
|
if local_player == clicked_player then -- Local player
|
||||||
if CheckIfCanBeCut(v) then
|
if CheckIfCanBeCut(v) and not CheckIfProsthesisAlreadyInstalled(local_toc_data, v) then
|
||||||
cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Cut", local_player, local_player)
|
cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Cut", local_player, local_player)
|
||||||
|
|
||||||
--cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TocCutLocal, local_player, local_player, v)
|
--cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TocCutLocal, local_player, local_player, v)
|
||||||
|
|||||||
@@ -99,15 +99,7 @@ local function IsPartBitten(part_data, part_name)
|
|||||||
return not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)):bitten()
|
return not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)):bitten()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CanLimbBeAmputated(toc_data, part_name)
|
|
||||||
|
|
||||||
local r = "Right"
|
|
||||||
local l = "Left"
|
|
||||||
|
|
||||||
return (string.find(part_name, r) and not (toc_data[r .. "Hand"].is_prosthesis_equipped or toc_data[r .. "Forearm"].is_prosthesis_equipped)) or
|
|
||||||
(string.find(part_name, l) and not (toc_data[l .. "Hand"].is_prosthesis_equipped or toc_data[l .. "Forearm"].is_prosthesis_equipped))
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function FindMinMax(lv)
|
local function FindMinMax(lv)
|
||||||
@@ -444,16 +436,16 @@ function SetupTocDescUI(surgeon, patient, toc_data, part_name)
|
|||||||
desc_ui["status"]:setText("Nothing here")
|
desc_ui["status"]:setText("Nothing here")
|
||||||
desc_ui["status"]:setColor(1, 1, 1, 1)
|
desc_ui["status"]:setColor(1, 1, 1, 1)
|
||||||
desc_ui["b1"]:setVisible(false)
|
desc_ui["b1"]:setVisible(false)
|
||||||
else
|
elseif CheckIfCanBeCut(part_name) then
|
||||||
-- Everything else
|
-- Everything else
|
||||||
-- TODO add check for cuts and scratches
|
-- TODO add check for cuts and scratches
|
||||||
desc_ui["status"]:setText("Not cut")
|
desc_ui["status"]:setText("Not cut")
|
||||||
desc_ui["status"]:setColor(1, 1, 1, 1)
|
desc_ui["status"]:setColor(1, 1, 1, 1)
|
||||||
if GetSawInInventory(surgeon) and CanLimbBeAmputated(toc_data, part_name) then
|
if GetSawInInventory(surgeon) and CheckIfProsthesisAlreadyInstalled(toc_data, part_name) then
|
||||||
desc_ui["b1"]:setVisible(true)
|
desc_ui["b1"]:setVisible(true)
|
||||||
desc_ui["b1"]:setText("Cut")
|
desc_ui["b1"]:setText("Cut")
|
||||||
desc_ui["b1"]:addArg("option", "Cut")
|
desc_ui["b1"]:addArg("option", "Cut")
|
||||||
elseif GetSawInInventory(surgeon) and not CanLimbBeAmputated(toc_data, part_name) then
|
elseif GetSawInInventory(surgeon) and not CheckIfProsthesisAlreadyInstalled(toc_data, part_name) then
|
||||||
desc_ui["b1"]:setVisible(true)
|
desc_ui["b1"]:setVisible(true)
|
||||||
desc_ui["b1"]:setText("Remove prosthesis before")
|
desc_ui["b1"]:setText("Remove prosthesis before")
|
||||||
desc_ui["b1"]:addArg("option", "Nothing")
|
desc_ui["b1"]:addArg("option", "Nothing")
|
||||||
|
|||||||
Reference in New Issue
Block a user