Solved Create a expression with skript-mirror

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

  • 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.

couger44

Supporter
Feb 19, 2017
713
31
28
Chile
Hi (Again).
While I was creating a skript, it occurred to me to create an expression that is something like this ->
code_language.skript:
json "text" with ttp "tools tip here" with cmd "/execute command here" to player(or all players)
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.
 
Last edited:
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:
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:
expression %integer% plus %integer%:
    return type: integer
    get:

Next, you need the actual code in the expression. Let's add that now.

Code:
expression %integer% plus %integer%:
    return type: integer
    get:
        set {_this} to expression-1 + expression-2

You have to specify expressions by expression- and then their number. Then, you return a value.

Code:
expression %integer% plus %integer%:
    return type: integer
    get:
        set {_this} to expression-1 + expression-2
        return {_this}

And that's how you basically make an expression. Hopefully that helped, if it did best answer me.
 
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:
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:
expression %integer% plus %integer%:
    return type: integer
    get:

Next, you need the actual code in the expression. Let's add that now.

Code:
expression %integer% plus %integer%:
    return type: integer
    get:
        set {_this} to expression-1 + expression-2

You have to specify expressions by expression- and then their number. Then, you return a value.

Code:
expression %integer% plus %integer%:
    return type: integer
    get:
        set {_this} to expression-1 + expression-2
        return {_this}

And that's how you basically make an expression. Hopefully that helped, if it did best answer me.
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".
 
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".
You could very easily make the expression return a json function. It'll work like this:
Code:
expression json %string% with ttp %string% for [player] %player%:
    get:
        return jsonFormat("%expression-3%", "%colored expression-1%||ttp:"%colored expression-2%")
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.
 
You could very easily make the expression return a json function. It'll work like this:
Code:
expression json %string% with ttp %string% for [player] %player%:
    get:
        return jsonFormat("%expression-3%", "%colored expression-1%||ttp:"%colored expression-2%")
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.
Thank you introducción for your helpmicals, I ended up doing it this way:
code_language.skript:
expression json %string% with ttp %string% with (1¦cmd|2¦url) %string% for [player] %player%:
    get:
        if expression-1 is set:
            if expression-2 is set:
                if parse mark = 1:
                    if expression-3 is set:
                        if expression-4 is set:
                            json("%expression-4%", "%colored expression-1%||ttp:%colored expression-2%||cmd:/%colored expression-3%")
                else if parse mark = 2:
                    if expression-3 is set:
                        if expression-4 is set:
                            json("%expression-4%", "%colored expression-1%||ttp:%colored expression-2%||url:%colored expression-3%")
 
Thank you introducción for your helpmicals, I ended up doing it this way:
code_language.skript:
expression json %string% with ttp %string% with (1¦cmd|2¦url) %string% for [player] %player%:
    get:
        if expression-1 is set:
            if expression-2 is set:
                if parse mark = 1:
                    if expression-3 is set:
                        if expression-4 is set:
                            json("%expression-4%", "%colored expression-1%||ttp:%colored expression-2%||cmd:/%colored expression-3%")
                else if parse mark = 2:
                    if expression-3 is set:
                        if expression-4 is set:
                            json("%expression-4%", "%colored expression-1%||ttp:%colored expression-2%||url:%colored expression-3%")
You are welcome! Thanks for the best answer and have a good day!
 
Status
Not open for further replies.