Created
February 4, 2018 04:50
-
-
Save Snow-Pyon/0abbde3aebe5d190122583affd792327 to your computer and use it in GitHub Desktop.
Util script to make manipulation of the play_server_chat packet easier.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
packet aliases for play_server_chat: | |
message of %packet% = chatcomponent pjson 0 of %packet% | |
message type of %packet% = "ChatType" penum 0 of %packet% | |
function toSkriptColor(color: text) :: text: | |
if {_color} contains "_": | |
replace all "_" with " " in {_color} | |
return {_color} | |
else if {_color} isn't "black", "white", "yellow" or "gold": | |
return "light %{_color}%" | |
else: | |
return {_color} | |
function toReadableText(json: jsonobject) :: text: | |
put json {_json} in listvar {_json::*} | |
loop tree of {_json::extra::*}: | |
if branch contains "color": | |
set {_color} to toSkriptColor("%loop-value%") | |
set {_color} to "<%{_color}%>" | |
else if branch contains "text": | |
if {_color} isn't set: | |
set {_color} to "" | |
add "%{_color}%%loop-value%" to {_full-text::*} | |
return join {_full-text::*} by "" | |
function toJsonComponent(input: text) :: jsonobject: | |
set {_component::extra::1::text} to {_input} | |
set {_component::text} to "" | |
return json of listvar {_component::*} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment