只显示当前血量: 删除所有 .."/"..valueMax
1 local function ShortValue(v) -- 显示 .K .M 2 if v >= 1e6 then 3 return ("%.1fm"):format(v / 1e6):gsub("%.?0+([km])$", "%1") 4 elseif v >= 1e3 or v <= -1e3 then 5 return ("%.1fk"):format(v / 1e3):gsub("%.?0+([km])$", "%1") 6 else 7 return v 8 end 9 end 10 11 --[[ 12 local function ShortValue(v) -- 不显示 .K .M 13 if v >= 1e6 then 14 return ("%.1fm"):format(v / 1e6):gsub("%.?0+([km])$", "%1") 15 else 16 return v 17 end 18 end 19 --]] 20 21 function TextStatusBar_UpdateTextString(textStatusBar) 22 local textString = textStatusBar.TextString; 23 if(textString) then 24 local value = textStatusBar:GetValue(); 25 local valueMin, valueMax = textStatusBar:GetMinMaxValues(); 26 27 if ( ( tonumber(valueMax) ~= valueMax or valueMax > 0 ) and not ( textStatusBar.pauseUpdates ) ) then 28 textStatusBar:Show(); 29 if ( value and valueMax > 0 and ( GetCVarBool("statusTextPercentage") or textStatusBar.showPercentage ) and not textStatusBar.showNumeric) then 30 if ( value == 0 and textStatusBar.zeroText ) then 31 textString:SetText(textStatusBar.zeroText); 32 textStatusBar.isZero = 1; 33 textString:Show(); 34 return; 35 end 36 value = tostring(math.ceil((value / valueMax) * 100)) .. "%"; 37 if ( textStatusBar.prefix and (textStatusBar.alwaysPrefix or not (textStatusBar.cvar and GetCVar(textStatusBar.cvar) == "1" and textStatusBar.textLockable) ) ) then 38 textString:SetText(textStatusBar.prefix.." "..ShortValue(textStatusBar:GetValue()).." ("..value..")"); 39 else 40 textString:SetText(ShortValue(textStatusBar:GetValue()).." ("..value..")"); 41 end 42 elseif ( value == 0 and textStatusBar.zeroText ) then 43 textString:SetText(textStatusBar.zeroText); 44 textStatusBar.isZero = 1; 45 textString:Show(); 46 return; 47 else 48 textStatusBar.isZero = nil; 49 if ( textStatusBar.capNumericDisplay ) then 50 value = ShortValue(value); 51 valueMax = ShortValue(valueMax); 52 end 53 if ( textStatusBar.prefix and (textStatusBar.alwaysPrefix or not (textStatusBar.cvar and GetCVar(textStatusBar.cvar) == "1" and textStatusBar.textLockable) ) ) then 54 textString:SetText(textStatusBar.prefix.." "..value.."/"..valueMax); 55 else 56 textString:SetText(value.."/"..valueMax); 57 end 58 end 59 60 if ( (textStatusBar.cvar and GetCVar(textStatusBar.cvar) == "1" and textStatusBar.textLockable) or textStatusBar.forceShow ) then 61 textString:Show(); 62 elseif ( textStatusBar.lockShow > 0 and (not textStatusBar.forceHideText) ) then 63 textString:Show(); 64 else 65 textString:Hide(); 66 end 67 else 68 textString:Hide(); 69 textString:SetText(""); 70 if ( not textStatusBar.alwaysShow ) then 71 textStatusBar:Hide(); 72 else 73 textStatusBar:SetValue(0); 74 end 75 end 76 end 77 end 78 79 80 81 SlashCmdList.RELOADUI = function() ReloadUI() end 82 SLASH_RELOADUI1 = "/rl"