Spoiler: show
- Code: Select all
if info.shieldRatio > 0 and info.userUnit:GetBlueprint().Defense.Shield.ShieldMaxHealth then
local ShieldMaxHealth = info.userUnit:GetBlueprint().Defense.Shield.ShieldMaxHealth
controls.shieldText:Show()
if info.userUnit:GetBlueprint().Defense.Shield.ShieldRegenRate then
controls.shieldText:SetText(string.format("%d / %d +%d/s", math.floor(ShieldMaxHealth*info.shieldRatio), info.userUnit:GetBlueprint().Defense.Shield.ShieldMaxHealth , info.userUnit:GetBlueprint().Defense.Shield.ShieldRegenRate))
else
controls.shieldText:SetText(string.format("%d / %d", math.floor(ShieldMaxHealth*info.shieldRatio), info.userUnit:GetBlueprint().Defense.Shield.ShieldMaxHealth ))
end
end
if info.shieldRatio > 0 and info.userUnit:GetBlueprint().Defense.Shield.ShieldMaxHealth == nil then
local ShieldMaxHealth = info.userUnit:GetBlueprint().Enhancements[getEnh.GetEnhancements(info.entityId).Back].ShieldMaxHealth
controls.shieldText:Show()
if info.userUnit:GetBlueprint().Enhancements[getEnh.GetEnhancements(info.entityId).Back].ShieldRegenRate then
controls.shieldText:SetText(string.format("%d / %d +%d/s", math.floor(ShieldMaxHealth*info.shieldRatio), ShieldMaxHealth , info.userUnit:GetBlueprint().Enhancements[getEnh.GetEnhancements(info.entityId).Back].ShieldRegenRate))
else
controls.shieldText:SetText(string.format("%d / %d", math.floor(ShieldMaxHealth*info.shieldRatio), ShieldMaxHealth ))
end
end
Replacement script
Spoiler: show
- Code: Select all
if info.shieldRatio > 0 then
local unitBp = info.userUnit:GetBlueprint()
local ShieldMaxHealth, ShieldRegenRate
if unitBp.Defense.Shield.ShieldMaxHealth > 0 then
ShieldMaxHealth = unitBp.Defense.Shield.ShieldMaxHealth
ShieldRegenRate = unitBp.Defense.Shield.ShieldRegenRate or 0
elseif unitBp.Enhancements[getEnh.GetEnhancements(info.entityId).Back].ShieldMaxHealth > 0 then
ShieldMaxHealth = unitBp.Enhancements[getEnh.GetEnhancements(info.entityId).Back].ShieldMaxHealth
ShieldRegenRate = unitBp.Enhancements[getEnh.GetEnhancements(info.entityId).Back].ShieldRegenRate or 0
elseif GetShieldParams(info.userUnit, 'MyShield') then
local CustomShield = GetShieldParams(info.userUnit, 'MyShield')
ShieldMaxHealth = CustomShield.ShieldMaxHealth or 0
ShieldRegenRate = CustomShield.ShieldRegenRate or 0
end
if ShieldMaxHealth > 0 then
controls.shieldText:Show()
if ShieldRegenRate > 0 then
controls.shieldText:SetText(string.format("%d / %d +%d/s", math.floor(ShieldMaxHealth*info.shieldRatio), ShieldMaxHealth, ShieldRegenRate))
else
controls.shieldText:SetText(string.format("%d / %d", math.floor(ShieldMaxHealth*info.shieldRatio), ShieldMaxHealth))
end
end
end
This is proposed to allow 4DC custom shield types to display without triggering a lua / ui error.
Resin