Other Custom effects and expressions 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!

btk5h

Addon Developer
Jan 25, 2017
154
159
0
Pyongyang, North Korea
As of skript-mirror 0.8.0, you can now create your own custom effects and expressions. These serve as a replacement for Skript functions with more features and more familiar syntax.

By combining custom syntax with reflection, it is now possible to extend Skript in ways previously only achievable through addons. In fact, in many cases, it is better to use skript-mirror's custom syntax instead of creating an addon:
  • Custom syntax is hot-reloadable (reloadable without restarting the server), just like other Skript features
  • Custom syntax does not require a compiler
  • It is much easier to achieve high quality standards—the learning curve is much smaller!
Let's start by creating a simple effect:
code_language.skript:
effect greet [the] world:
  broadcast "Hello, world!"

command /tutorial1:
  trigger:
    greet world
    greet the world
Notice, we can use the same Skript features, like [brackets] and (curvy brackets|parentheses).

We can even use expressions:
code_language.skript:
effect greet %string%:
  broadcast "Hello, %expression-1%"
And if we want, we can accept multiple expressions as input. Notice how the type parameter is strings and we use expressions-1 instead of expression-1.
code_language.skript:
effect greet %strings%:
  loop expressions-1:
    broadcast "Hello, %loop-expression%"

command /tutorial2 <text>:
  trigger:
    greet argument split by " "
Running /tutorial2 Alice Bob prints "Hello, Alice" and "Hello, Bob".

We can even use waits and delays:
code_language.skript:
effect greet [the] world slowly:
  broadcast "Hello"
  wait 5 seconds
  broadcast "World"

command /tutorial3:
  trigger:
    greet the world slowly
    broadcast "end"
However, this example prints "Hello", "end", then "World". This is because Skript is not waiting for the effect to complete before it continues with the following code. (This is how functions behave, too.)

In order to fix this, we must indicate that the effect will be delayed before the delay occurs. We must also add continue at the end to indicate that the effect has ended and the code can continue to execute.
code_language.skript:
effect greet [the] world slowly:
  delay the effect
  broadcast "Hello"
  wait 5 seconds
  broadcast "World"
  continue

command /tutorial3:
  trigger:
    greet the world slowly
    broadcast "end"
This prints "Hello", "World", "end", as you might expect.

You may notice we now have a greet [the] world effect and a greet [the] world slowly effect. We can combine the logic for these two effects into a single effect using parser marks.
code_language.skript:
effect greet [the] world [(1¦slowly)]:
  if parse mark is 1:
    delay the effect
    broadcast "Hello"
    wait 10 seconds
    broadcast "World"
    continue
  else:
    broadcast "Hello, world!"
Notice, the latter branch of the if statement does not need a continue because it never reaches a line that delays the expression.

Expression tutorial coming soon. For now, you can read this tutorial for a taste of expressions.
 
Hooking into Bukkit events is already possible. I may add support for user-defined events if the syntax is simple enough.
If possible I would prefer user-defined types since custom events are already possible with mundosk. Also thanks for adding effects and expressions, they are really useful
 
As for creating our own types, enums which support your standard bit mask logic could be cool. Or just bitwise operators in general.

This looks awesome, though.
 
I'm having troubles understanding the delay and how you access custopm effects...

I'm trying to add a "function" in which i check for a value in the database and return either false or the value if its not set/set

something like this:

code_language.skript:
effect check %player%:
        delay the effect
        execute "SELECT * from inventory.`%unsafe uuid of {_p}%`" in {db} and store output in {_e::*}
        if {_e::*} is set:
                send "%{_e::*}%" to expr-1
                return {_e::*}
        else:
                return false


command /equip:
        permission: *
        trigger:
                check player

keeps giving me "can't understand condition/effect: check" so i dont even know if the custom effect is correct....
Can someone give me an example on how to solve this? I dont even know what im doing wrong i tried every way of accessing the custom effect that comes to my mind

using skript-mirror 0.9 and dev33
 
Last edited:
It's an already known bug of dev30+, you'll have to put the custom effect in another script that is loaded before the script that is using the custom effect for it to work.
Of course its the one thing i thought about trying but didnt because i thought that cant be.
well thats pretty annoying especially if you try to create functions that call other functions, any chance this will be fixed soon?
 
Of course its the one thing i thought about trying but didnt because i thought that cant be.
well thats pretty annoying especially if you try to create functions that call other functions, any chance this will be fixed soon?
this isn't the case of functions, only of skript-mirror custom syntaxes. I'll see if I can fix it, no promises though.
 
Can someone help me out with this?
im trying to make a "function" that waits for some data from luckperms but i only get <none>s
code_language.skript:
expression last permissioncheck %offline player%:
        get:
                return {permissioncheck}
        set:
                set {permissioncheck} to change value
        delete:
                delete {permissioncheck}

effect permissioncheck %offline player%:
        trigger:
                if expr-1.getLastPlayed() is 0:
                        set permissioncheck to "Unknown"
                        stop
                else:
                        delay the effect
                        set {_api} to LuckPerms.getApi()
                        set {_uuid} to {_p}.getUniqueId()
                        {_api}.getUserManager().loadUser({_uuid})
                        loop 10 times:
                                wait 1 tick
                                {_api}.getUserManager().isLoaded({_uuid}) is true
                                stop loop
                        set permissioncheck to "%{_u}.getPermissions()%"
                        continue

command /test <offline player>:
        permission: *
        trigger:
                send "%last permissioncheck arg-1%"
i tried to work with existing posts, the docs and even discord history but i just cant find any helpful examples or some sort of more detailed documentation.
just want to make a function that returns either a string of permission nodes or "Unknown"
[doublepost=1544810330,1544508905][/doublepost]can someone help me please?

i just need a function which returns a string after a lookup and allows a delay

or can i only put the full code in front of everything where i need it?