我说的是rbx.Lua,所以如果你不是很了解它,不要尝试回答这个问题
function ConvertShort(num, cool)
local x = tostring(num)
if #x >= 16 then
local important = (#x - 15)
cool.Value = x:sub(0,(important)).."."..(x:sub(#x-13,(#x-13))).."qd"
elseif #x >= 13 then
local important = (#x-12)
cool.Value = x:sub(0,(important)).."."..(x:sub(#x-10,(#x-10))).."T"
elseif #x>= 10 then
local important = (#x - 9)
cool.Value = x:sub(0,(important)).."."..(x:sub(#x-7,(#x-7))).."B"
elseif #x >= 7 then
local important = (#x-6)
cool.Value = x:sub(0,(important)).."."..(x:sub(#x-5,(#x-5))).."M"
elseif #x >= 4 then
cool.Value = x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."k"
end
end
game.Players.PlayerAdded:connect(function(plr)
local cash = Instance.new("StringValue", plr)
cash.Name = "cash"
cash.Value = "0"
cash.Changed:connect(function()
ConvertShort(tonumber(cash.Value), cash)
end)
end)所以,当它达到万亿的时候,它会显示出像1e+1.1k这样的小块头,这不是我想要的样子,我需要它更像"1qd",而我不知道如何解决这个问题,也不知道是否有办法。
发布于 2016-05-14 10:17:02
替换
local x = tostring(num)使用以下代码:
local x = ""
while num >= 1000000 do
x, num = x.."0", math.floor(num / 10)
end
x = tostring(num)..x发布于 2016-05-16 12:53:10
替换
local x = tostring(num)使用
local x = string.format("%.0f", num)https://stackoverflow.com/questions/37221518
复制相似问题