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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

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

Solved Create a expression with skript-mirror

Discussion in 'Skript' started by couger44, Mar 29, 2019.

Thread Status:
Not open for further replies.
  1. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    Hi (Again).
    While I was creating a skript, it occurred to me to create an expression that is something like this ->
    Code (Skript):
    1.  
    2. json "text" with ttp "tools tip here" with cmd "/execute command here" to player(or all players)
    3.  
    Of course, i need the json.sk API, but I want to create this to avoid the mess of putting json ("all this ...") and make it easier for me. I do not say that I want to create a json from 0, if not create an expression that makes its use easier.

     
    #1 couger44, Mar 29, 2019
    Last edited: Mar 29, 2019
  2. Best Answer:
    Post #4 by CormanYT, Mar 31, 2019
  3. CormanYT

    CormanYT Active Member

    Joined:
    Jan 6, 2018
    Messages:
    122
    Likes Received:
    4
    Alright, here's where I come in. Also I don't know the more advanced part of this, but I'll give it a shot.
    (give best answer if it works).

    As you said, it requires skript-mirror

    So, you first need to choose an expression name and arguments for it.

    Code (Text):
    1. expression %integer% plus %integer%:
    You can do more advanced stuff for the name like (%player%'s last thing|last thing of %player%) or optional lines like [the] %player%'s food bar and etc. But that's the start of it.

    Next, you need get. Just like a command, you need something to start it. You can also specify a return type (not required though). Here's my example so far:

    Code (Text):
    1. expression %integer% plus %integer%:
    2.     return type: integer
    3.     get:
    Next, you need the actual code in the expression. Let's add that now.

    Code (Text):
    1. expression %integer% plus %integer%:
    2.     return type: integer
    3.     get:
    4.         set {_this} to expression-1 + expression-2
    You have to specify expressions by expression- and then their number. Then, you return a value.

    Code (Text):
    1. expression %integer% plus %integer%:
    2.     return type: integer
    3.     get:
    4.         set {_this} to expression-1 + expression-2
    5.         return {_this}
    And that's how you basically make an expression. Hopefully that helped, if it did best answer me.
     
  4. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    I appreciate your help, but that was not my question. My question was, what could be done to make it easier to use the "json", that is to create an expression with the functions of "json".
     
  5. CormanYT

    CormanYT Active Member

    Joined:
    Jan 6, 2018
    Messages:
    122
    Likes Received:
    4
    You could very easily make the expression return a json function. It'll work like this:
    Code (Text):
    1. expression json %string% with ttp %string% for [player] %player%:
    2.     get:
    3.         return jsonFormat("%expression-3%", "%colored expression-1%||ttp:"%colored expression-2%")
    4.    
    That should allow you to use this: json "Hello" with ttp "Yes!" for player

    It's a bit tricky to do but that should work.
     
    • Informative Informative x 1
  6. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    Thank you introducción for your helpmicals, I ended up doing it this way:
    Code (Skript):
    1.  
    2. expression json %string% with ttp %string% with (1¦cmd|2¦url) %string% for [player] %player%:
    3.     get:
    4.         if expression-1 is set:
    5.             if expression-2 is set:
    6.                 if parse mark = 1:
    7.                     if expression-3 is set:
    8.                         if expression-4 is set:
    9.                             json("%expression-4%", "%colored expression-1%||ttp:%colored expression-2%||cmd:/%colored expression-3%")
    10.                 else if parse mark = 2:
    11.                     if expression-3 is set:
    12.                         if expression-4 is set:
    13.                             json("%expression-4%", "%colored expression-1%||ttp:%colored expression-2%||url:%colored expression-3%")
    14.  
    15.  
     
  7. CormanYT

    CormanYT Active Member

    Joined:
    Jan 6, 2018
    Messages:
    122
    Likes Received:
    4
    You are welcome! Thanks for the best answer and have a good day!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...