Get last color of a string

  • 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 community!

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

SkriptStorm

Member
Jun 17, 2020
4
0
1
location of "SkriptStorm"
Is there a way to get the last color of a string?
Example:
Code:
set {_test} to color of "&cText&bHello"
send uncolored "%{_test}%"
It would be "&b"

Skript Version: Latest
Minecraft Version: 1.15.2
 
Here's how I would go about it.
Code:
command /fm <text>:
  trigger:
    set {_test::*} to split (colored arg-1) at "§" # § is the color code in minecraft, a colored text will replace all instances of &<colorcode> with §<colorcode>
    set {_size} to size of {_test::*} # We get the size of the list because whatever the size is will be the same as the index of it's last element
    set {_answer} to {_test::%{_size}%} # The last element of the list.
    set {_color} to "§%first character of {_answer}%This Color" # We get the first letter which is the color code and attatch it to § making it colored.
    message {_color}
 
Here's how I would go about it.
Code:
command /fm <text>:
  trigger:
    set {_test::*} to split (colored arg-1) at "§" # § is the color code in minecraft, a colored text will replace all instances of &<colorcode> with §<colorcode>
    set {_size} to size of {_test::*} # We get the size of the list because whatever the size is will be the same as the index of it's last element
    set {_answer} to {_test::%{_size}%} # The last element of the list.
    set {_color} to "§%first character of {_answer}%This Color" # We get the first letter which is the color code and attatch it to § making it colored.
    message {_color}
That works great, but is there a way to get §l, §o, §m, §k, and §r in there too?
 
Status
Not open for further replies.