Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I abbreviate cash above Billions in Zednov's Tycoon Kit?

Asked by 2 years ago
Edited 2 years ago

So in Zednov's tycoon kit, theres a script called settings. This abbreviates 1,000 cash into 1K and 1,000,000 into 1M, and 1,000,000,000 into 1B. But there is nothing above that. I'd like for someone to help me with making 1T, 1Qd, 1Qn, to like De or something. I would love to know how to do this since the script looks confusing as hell and I have no idea how to script:

Script:

function module:ConvertComma(num)
    local x = tostring(num)
    if #x>=10 then
        local important = (#x-9)
        return x:sub(0,(important))..","..x:sub(important+1,important+3)..","..x:sub(important+4,important+6)..","..x:sub(important+7)
    elseif #x>= 7 then
        local important = (#x-6)
        return x:sub(0,(important))..","..x:sub(important+1,important+3)..","..x:sub(important+4)
    elseif #x>=4 then
        return x:sub(0,(#x-3))..","..x:sub((#x-3)+1)
    else
        return num
    end
end

function module:ConvertShort(Filter_Num)
    local x = tostring(Filter_Num)
    if #x>=10 then
        local i
        local important = (#x-9)
        return x:sub(0,(important)).."."..(x:sub(#x-7,(#x-7))).."B+"
    elseif #x>= 7 then
        local important = (#x-6)
        return x:sub(0,(important)).."."..(x:sub(#x-5,(#x-5))).."M+"
    elseif #x>=4 then
        return x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
    else
        return Filter_Num
    end
end

return module

--End of script

As you see, theres only K+, M+, and B+... I need higher ones...

0
If this is confusing just search up Zednov's Tycoon Kit in toolbox and find the script that says settings and scroll down to the bottom. Krektonix_Youtube 85 — 2y

1 answer

Log in to vote
2
Answered by 2 years ago

To abbreviate numbers above a billion, you have to create a new if statement, for this example I'm going to abbreviate the trillion and quadrillion. But, you can abbreviate to whatever large number you want. The first step is to get the scientific notation of the number you want to abbreviate which you can get here. The second step is to go to the Settings module, scroll down to the ConvertShort function and after the code snippet:

local x = tostring(Filter_Num)

Write:

if #x>=(the exponent number plus one (1))
    local important = (#x-(the exponent number))
    return x:sub(0,(important)).."."..(x:sub(#x-(exponent number minus 2),(#x-(exponent number minus 2).."(whatever abbreviation you want)"
end

Now here is an example with trillion and quadrillion:

if #x>=16 then
        local important = (#x-15)
        return x:sub(0,(important)).."."..(x:sub(#x-14,(#x-14))).."Qd+"
end
    if #x>=13 then
        local important = (#x-12)
        return x:sub(0,(important)).."."..(x:sub(#x-11,(#x-11))).."T+"
end
0
Hey, hope this helped! If not, comment under this and I will get back to you as soon as possible. MendozaHM3SBulldog 32 — 2y
0
Where should I put this? Because the if statements run across every #x>=(numberhere) then using elseif Krektonix_Youtube 85 — 2y
0
Nevermind, thank you! This worked. So I can keep adding like Qn+, Sx+, Sp+ ? Krektonix_Youtube 85 — 2y
0
Yes, but remember to get the scientific notations from the wikipedia page I linked. For example, for Qn+ it would be important = (#x-18) (as the notation is 10^18) (x:sub(#x-13,(#x-13))).."Qn+ MendozaHM3SBulldog 32 — 2y
View all comments (2 more)
0
Thanks! Krektonix_Youtube 85 — 2y
0
This really helps because I have a rebirth system and you get new buttons each rebirth. So, most buttons go over billions of dollars! Krektonix_Youtube 85 — 2y
Ad

Answer this question