i want to make a HUD with the text sprite extention, but i don’t exactly know how. can someone help me?
You can update a text sprite in an on update
block if you’re not sure when a value will change. Otherwise, you can use some other sort of event handler, like for a button press, if you know when you want the text sprite to change.
Take a look below for examples of all of these. Press the A and B buttons to change the text sprites in the middle of the screen.
use the set(textSprite) text “”
to change the code it can also use unicode
and use the convert to text and join
now if you want to make a number from 1200000 to 1.2m or 1000 to 1k so abbreviate Number function. but you need spriteUtile extension
abbreviateNumber function
function abbreviateNumber(Value: number, Desimal: number) {
if (1000 <= Math.sqrt(Value ** 2) && !(1000000 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1000, Desimal)) + "K"
} else if (1000000 <= Math.sqrt(Value ** 2) && !(1000000000 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1000000, Desimal)) + "M"
} else if (1000000000 <= Math.sqrt(Value ** 2) && !(1000000000000 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1000000000, Desimal)) + "B"
} else if (1000000000000 <= Math.sqrt(Value ** 2) && !(1000000000000000 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1000000000000, Desimal)) + "T"
} else if (1000000000000000 <= Math.sqrt(Value ** 2) && !(1000000000000000000 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1000000000000000, Desimal)) + "Qua"
} else if (1000000000000000000 <= Math.sqrt(Value ** 2) && !(1e+21 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1000000000000000000, Desimal)) + "Qui"
} else if (1e+21 <= Math.sqrt(Value ** 2) && !(1e+24 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+21, Desimal)) + "S"
} else if (1e+24 <= Math.sqrt(Value ** 2) && !(1e+27 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+24, Desimal)) + "Sep"
} else if (1e+27 <= Math.sqrt(Value ** 2) && !(1e+30 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+27, Desimal)) + "Oct"
} else if (1e+30 <= Math.sqrt(Value ** 2) && !(1e+33 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+30, Desimal)) + "Non"
} else if (1e+33 <= Math.sqrt(Value ** 2) && !(1e+36 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+33, Desimal)) + "Dec"
} else if (1e+36 <= Math.sqrt(Value ** 2) && !(1e+39 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+36, Desimal)) + "Und"
} else if (1e+39 <= Math.sqrt(Value ** 2) && !(1e+42 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+39, Desimal)) + "Duo"
} else if (1e+42 <= Math.sqrt(Value ** 2) && !(1e+45 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+42, Desimal)) + "Tre"
} else if (1e+45 <= Math.sqrt(Value ** 2) && !(1e+48 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+45, Desimal)) + "Quat"
} else if (1e+48 <= Math.sqrt(Value ** 2) && !(1e+51 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+48, Desimal)) + "Quin"
} else if (1e+51 <= Math.sqrt(Value ** 2) && !(1e+54 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+51, Desimal)) + "Sexde"
} else if (1e+54 <= Math.sqrt(Value ** 2) && !(1e+57 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+54, Desimal)) + "Septe"
} else if (1e+57 <= Math.sqrt(Value ** 2) && !(1e+60 <= Math.sqrt(Value ** 2))) {
return "" + convertToText(roundWithPrecision(Value / 1e+57, Desimal)) + "Octod"
} else if (1e+60 <= Math.sqrt(Value ** 2)) {
return "" + convertToText(roundWithPrecision(Value / 1e+60, Desimal)) + "Novem"
} else {
return convertToText(roundWithPrecision(Value, Desimal))
}
}
i made a better and more user friendly abbreviate Number function, with a better round to decimal function the the one from spriteUtile
abbreviateNumber function
function abbreviateNumber(value: number, Decimals: number) {
numlist = [
["K", "1000"],
["M", "1000000"],
["B", "1000000000"],
["T", "1000000000000"],
["Qa", "1000000000000000"],
["Qi", "1000000000000000000"],
["Sx", "1e+21"],
["Sp", "1e+24"],
["Oc", "1e+27"],
["No", "1e+30"],
["Dc", "1e+33"],
["Ud", "1e+36"],
["Dd", "1e+39"],
["Td", "1e+42]"],
["Qad", "1e+45"],
["Qid", "1e+48"],
["Sxd", "1e+51"],
["Spd", "1e+54"],
["Ocd", "1e+57"],
["Nod", "1e+60"],
["Vg", "1e+63"]
]
Position = Math.floor((convertToText(value).length - 1) / 3) - 1
abbr = "" + convertToText(roundToDecimal(value / parseFloat(numlist[Position][1]), Decimals)) + numlist[Position][0]
return abbr
}
roundToDecimal function
function roundToDecimal (num: number, decimalPlaces: number) {
factor = 10 ** decimalPlaces
return Math.round(num * factor) / factor
}
i also made a game with the text sprite extension
You just have to update it when the number changes
please dont @ me in a conversation that im not a part of. i get a notification and think to myself “this person @ 'ed me, they probably want to talk.” but then when i check the topic, that isn’t the case and the person in question just used my username to talk with someone else. if you want to mention me in a conversation, great, go for it, just please dont use @.
You know @ing someone means mentioning them right? I though this conversation was relevant, but I won’t @ you if it bothers you that much