From 6512bb34ae31a746fb14ca5cbb1ddaf8f117771b Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 9 May 2020 02:37:46 +0200 Subject: [PATCH] api: support to also abbreviate negative values --- api/api.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/api.lua b/api/api.lua index 10ca0e08..35cc95cb 100644 --- a/api/api.lua +++ b/api/api.lua @@ -296,10 +296,13 @@ end -- 'returns: [string] the abbreviated value function pfUI.api.Abbreviate(number) if pfUI_config.unitframes.abbrevnum == "1" then + local sign = number < 0 and -1 or 1 + number = math.abs(number) + if number > 1000000 then - return pfUI.api.round(number/1000000,2) .. "m" + return pfUI.api.round(number/1000000*sign,2) .. "m" elseif number > 1000 then - return pfUI.api.round(number/1000,2) .. "k" + return pfUI.api.round(number/1000*sign,2) .. "k" end end