PitBull4 數值換算單位再次修正

這次又修改了PitBull4 DogText短格式數值換算單位,
改成不到十萬的值都顯示精確值,
達十萬才開始換算,
十萬以上不到一百萬的值可顯示一位小數,
一百萬以上不到一億的值則為整數,
而若有破億的值都顯示兩位小數並以億為單位。

修改 PitBull4_DogTagTexts\libs\LibDogTag-3.0\Categories\TextManip.lua,
原始內容:
[ccen_lua first_line=”28″]
if type(value) == “number” then
if value >= 10000000 or value <= -10000000 then
return (“%.1fm”):format(value / 1000000)
elseif value >= 1000000 or value <= -1000000 then
return (“%.2fm”):format(value / 1000000)
elseif value >= 100000 or value <= -100000 then
return (“%.0fk”):format(value / 1000)
elseif value >= 10000 or value <= -10000 then
return (“%.1fk”):format(value / 1000)
else
return math.floor(value+0.5)..”
end
else
local a,b = value:match(“^(%d+)/(%d+)$”)
if a then
a, b = tonumber(a), tonumber(b)
if a >= 10000000 or a <= -10000000 then
a = (“%.1fm”):format(a / 1000000)
elseif a >= 1000000 or a <= -1000000 then
a = (“%.2fm”):format(a / 1000000)
elseif a >= 100000 or a <= -100000 then
a = (“%.0fk”):format(a / 1000)
elseif a >= 10000 or a <= -10000 then
a = (“%.1fk”):format(a / 1000)
end
if b >= 10000000 or b <= -10000000 then
b = (“%.1fm”):format(b / 1000000)
elseif b >= 1000000 or b <= -1000000 then
b = (“%.2fm”):format(b / 1000000)
elseif b >= 100000 or b <= -100000 then
b = (“%.0fk”):format(b / 1000)
elseif b >= 10000 or b <= -10000 then
b = (“%.1fk”):format(b / 1000)
end
[/ccen_lua]
改成:
[ccen_lua first_line=”28″]
if type(value) == “number” then
if value >= 100000000 or value <= -100000000 then
return (“%.2f億”):format(value / 100000000)
elseif value >= 1000000 or value <= -1000000 then
return (“%.0f萬”):format(value / 10000)
elseif value >= 100000 or value <= -100000 then
return (“%.1f萬”):format(value / 10000)
else
return math.floor(value+0.5)..”
end
else
local a,b = value:match(“^(%d+)/(%d+)$”)
if a then
a, b = tonumber(a), tonumber(b)
if a >= 100000000 or a <= -100000000 then
a = (“%.2f億”):format(a / 100000000)
elseif a >= 1000000 or a <= -1000000 then
a = (“%.0f萬”):format(a / 10000)
elseif a >= 100000 or a <= -100000 then
a = (“%.1f萬”):format(a / 10000)
end
if b >= 100000000 or b <= -100000000 then
b = (“%.2f億”):format(b / 100000000)
elseif b >= 1000000 or b <= -1000000 then
b = (“%.0f萬”):format(b / 10000)
elseif b >= 100000 or b <= -100000 then
b = (“%.1f萬”):format(b / 10000)
end
[/ccen_lua]

pitbull4_fix

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料