Jump to content

Recommended Posts

function hex(r: integer, g: integer, b: integer) :: string:
	set {_indices::*} to split "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15" at ","
	set {_convert::*} to split "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F" at ","
	loop "r", "g" and "b":
		set {_number} to {_%loop-value%} / 16
		set {_decimal} to {_number} - floor({_number})
		set {_number} to {_number} - {_decimal}
		set {_decimal} to {_decimal} * 16
		loop "number" and "decimal":
			clear {_index}
			loop {_indices::*}:
				add 1 to {_index}
				"%{_%loop-value-2%}%" = loop-value-3:
					set {_return::*} to {_return::*} and {_convert::%{_index}%}
					stop loop
	return "##%join {_return::*} by """"%"

Function to convert RGB into Hex colors... I hope this will be useful when Skript or related add-ons support custom colors in text components. 

 

Check out this blog post in order to find out how RGB and Hex relate.

 

Please DM me on Discord (dinomite#0432) if there are any bugs or questions.

 

Edited by dinomite
Link to post
Share on other sites
  • 2 weeks later...

I created a way to implement the above function now that Minehut has updated (I know I may be late).

function rgb_color(r: integer, g: integer, b: integer) :: string:
	set {_hex} to subtext of hex({_r}, {_g}, {_b}) from characters 2 to length of hex({_r}, {_g}, {_b})
	set {_hex::*} to split {_hex} at ""
	set {_size} to size of {_hex::*}
	delete {_hex::%{_size}%}
	return colored "&x&%join {_hex::*} by ""&""%"

For example, you can do:

send colored "%rgb_color(255, 0, 0)%&lWARNING! &fThere may be bugs!"

In order to send a nice-looking message that looks like this:

image.png.a2b0a001415a4660c6e20c597780cf0d.png

 

This is for people who would rather use RGB over Hex. Enjoy! 😄 

Link to post
Share on other sites

huhu

 

My version;

its a little bit shorter

function RGB(r:integer,g:integer,b:integer) :: string:
    set {a::*} to "&0","&1","&2","&3","&4","&5","&6","&7","&8","&9","&a","&b","&c","&d","&e" and "&f"
    set {_r::*} to {_r},{_g} and {_b}
    loop {_r::*}:
        set {_st} to join {_st},{a::%((loop-value-mod(loop-value,16))/16+1)%} and {a::%mod(loop-value,16)+1%} with ""
    return "&x%{_st}%"

 

Link to post
Share on other sites
  • 2 weeks later...

I made HSL to RGB To Minecraft hex, i didnt know this existed, so heres my version

function singleRgbColorToHex(c: number) :: text:
    set {_r} to ""
    set {_m} to mod({_c}, 16)
    set {_d} to mod(ceil({_c} / 16) - 1, 16)
    loop 2 times:
        if loop-number is 1:
            set {_v} to {_m}
        else:
            set {_v} to {_d}
        if {_v} = 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9:
            set {_r} to "%{_r}%&%{_v}%"
        else:
            if {_v} = 10:
                set {_r} to "%{_r}%&a"
            else if {_v} = 11:
                set {_r} to  "%{_r}%&b"
            else if {_v} = 12:
                set {_r} to "%{_r}%&c"
            else if {_v} = 13:
                set {_r} to "%{_r}%&d"
            else if {_v} = 14:
                set {_r} to "%{_r}%&e"
            else if {_v} = 15:
                set {_r} to "%{_r}%&f"
    return {_r}



you would run this for every color in the rgb, once for r, once for g, once for b.

EDIT: Heres what it would look like if you mixed the hsl to rgb to minecraft hex all together: https://gyazo.com/8a57736c37bff984e6c879a6c2a5ec6d
Or without rainbow gradient: https://gyazo.com/59e64e155ee4c3733904e3d4d8c084c4
Things like this would look great on a bossbar or as a donator perk!

Edited by 3Q6Dev

Click Next Page to view my forum signature.


#UnbanMooMoo

#Unban3Q6

Image too large, view here: https://3q6dev.tk/images/MinehutOriginal3.png

Super League Gaming Loses $14.5 million on $1 million in revenue in 2019

 

 

 

Link to post
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...