Jump to content

Skript Numbers


ItsKirby

Recommended Posts

function fancynum(i: text) :: text:
 set {_r} to ""
 if {_i} contains ".":
  set {_ni::*} to {_i} split at "."
  set {_l} to {_ni::1}'s length
 else:
  set {_l} to {_i}'s length
 loop {_l} times:
  set {_r} to "%subtext of {_i} from {_l}-loop-value+1 to {_l}-loop-value+1%%{_r}%"
  if mod(loop-value, 3) = 0:
   if loop-value is not {_l}:
    set {_r} to ",%{_r}%"
 if {_ni::2} is set:
  if {_ni::2}'s length = 1:
   set {_r} to "%{_r}%.%{_ni::2}%0"
  else:
   set {_r} to "%{_r}%.%{_ni::2}%"
 return {_r}

There that should do it

To use it just write something like

set {_price} to fancynum("%{price::item1}%")

 

Edited by Starshinex3

tumblr_lqahoaPLkC1ql1l0v.gif

Feel free to add me on discord if you:

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need help with plugins

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need help with skripts

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need to vent about something

tumblr_lqahoaPLkC1ql1l0v.gif

>[ ‧₊˚꒰ʚ Starshine ɞ ‧✦ *#2683 ]<

Link to comment
Share on other sites

36 minutes ago, Starshinex3 said:

function fancynum(i: text) :: text:
 set {_r} to ""
 if {_i} contains ".":
  set {_ni::*} to {_i} split at "."
  set {_l} to {_ni::1}'s length
 else:
  set {_l} to {_i}'s length
 loop {_l} times:
  set {_r} to "%subtext of {_i} from {_l}-loop-value+1 to {_l}-loop-value+1%%{_r}%"
  if mod(loop-value, 3) = 0:
   if loop-value is not {_l}:
    set {_r} to ",%{_r}%"
 if {_ni::2} is set:
  if {_ni::2}'s length = 1:
   set {_r} to "%{_r}%.%{_ni::2}%0"
  else:
   set {_r} to "%{_r}%.%{_ni::2}%"
 return {_r}

There that should do it

To use it just write something like


set {_price} to fancynum("%{price::item1}%")

 

Here is an easier way to do that

function spaced(n: text) :: text:
   set {_s::*} to split {_n} at "."
   if {_s::*} is not set:
       return a({_n})
   else:
       return "%a({_s::1})%.%{_s::2}%"
 
function a(b: text) :: text:
   if length of {_b} > 3:
       return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
   return {_b}

Then to use it, do spaced("%{variable}%")

 

Not my skript btw

Discord - tarna256

In-game name - _Tarna_

Website - https://tarna.dev
Paste Site: https://paste.tarna.dev

---------------------------------------------------------

[VIP] - 7/27/2020

Community Support - 7/8/20 | 11/3/20

Helper  - 11/3/20 - 2/21/21

Moderator - 2/21/21 - 5/17/21

❤️ - 5/17/21 - now

Moderator - 12/20/22 - now

---------------------------------------------------------

image.png.70849a9b84e0347ce107b8e3eaee312c.pngimage.png.2111009afbd8bef10966ba9ede35a199.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...