1. 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 comminuty!

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

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Skript JSON Text Guide for Newbies

Discussion in 'Tutorials' started by jjpwn1, Sep 10, 2018.

  1. j

    jjpwn1 Member

    Joined:
    Aug 18, 2018
    Messages:
    12
    Likes Received:
    4
    In Skript it is possible to create basic json texts that are the equivalence to Vanilla Minecraft's /tellraw command.

    However, the proper documentation surrounding them can be hard to find and at times lack critical information for new skripters. In addition, there are many unsolved and hidden bugs concerning Skript's native json. All of these factors ultimately leads to a frustrating and painful experience especially for new Skripters. That's why I created this tutorial, which is to clear up confusion regarding this issue.

    Before reading my tutorial, I suggest you to read the official documentation regarding json text. After all, this tutorial serves as an clarification to it.
    -------------------
    Basics:
    Json parameters should be treated as similarly to Skript's <colour> colour codes. Json texts should start with their initial parameters, and end with <reset>. <reset> lets the code know when to stop. In other words, anything in between the <> and <reset> will be affected by whatever action you set to it. Please keep in mind that when <reset> is not included, it will assume that everything after the <> will be affected.

    For example:
    Code (Skript):
    1. command /jsontext:
    2.     trigger:
    3.         message "<tooltip:hello world>Hover me for a tooltip!<reset>"
    With this code, if you enter /jsontext, a text will popup which will display "hello world" when you hover over it.


    <reset> also lets you to have certain parts of the message not be affected by json.
    Code (Skript):
    1. command /jsontext:
    2.     trigger:
    3.         message "<tooltip:hello world>This sentence will have a tooltip.<reset> However, this sentence will not!"
    With this code, if you enter /jsontext, a text will popup where hovering only the first sentence will display "hello world" while the other will not.

    Lastly, Skript allows you to have multiple parameters for json text. This is easy to implement by simply adding another <> parameter right next to the existing one.

    For example:
    Code (Skript):
    1. command /jsontext:
    2.     trigger:
    3.         message "<tooltip:sercet message><run command:/help>Hover me to see a message, and click me to run /help !<reset>"
    With this code, a secret message will display when you hover over it, and a command /help will be executed when you click on it.
    -------------------
    Issues:
    Skript's native json is incredibly nitpicky about it's parameters and on how it should be used.

    For example, typing <run_command:/cmd> will not work, but <run command:/cmd> will.

    Using </run command:/cmd> to end a parameter would not work. This is strange especially because colour codes ( <red>This text is red</red>) works with no issues. In other words, attempting to "end" a parameter can only be done so using <reset> (as far as I know).

    Some events such as on chat does not work with json, according to an issue on their GitHub.

    According to another issue, you cannot set a json text to a variable either and expect it to work.

    All and all, you should ideally only use Skript's native json text formatting for extremely basic purposes for now, as most issues you'll experience from it would more often than not be from a bug on Skript's part and not your own, in which that case you should report the issue to their GitHub. For more advanced json stuff though, I suggest you to head over on to json.sk instead.
     
    • Like Like x 4
Loading...