formated number function request

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

titustitus98

Member
Feb 19, 2018
47
0
6
26
Category: Function

Suggested name:
format.sk
Spigot/Skript Version:
1.12.2
What I want:
What I need is a function to format number (1k, 1m, 1b...)

Ideas for commands:
none
Ideas for permissions:
none
When I'd like it by: A couple days
 
Use
Code:
function formatNum(n: number) :: string:
    set {_l::*} to split "k,M,B,T,Qn,Qi,Sx" at ","
    set {_i} to min(floor(log({_n})/3), size of {_l::*})
    return "%{_n}%" if {_i} <= 0
    set {_i2} to 1000^{_i}
    return "%{_n}/{_i2}%%{_l::%{_i}%}%"
(from here)