Skript: Target selectors for scripted commands

Created on 11 Jun 2019  路  10Comments  路  Source: SkriptLang/Skript

Hello,

I'm trying to use some skripts in command blocks in 1.13.2 but nothing happened when I active these command blocks, no result at all.

I tested :

PS:

  • I use the 2.4-alpha3 version of skript
  • Everything works in 1.12.2
  • commandname returns simply a broadcasted message

Can you help me ?

Thanking you in advance,

Killance

enhancement low

All 10 comments

If I'm not mistaken, this isn't a Skript issue, this is a Spigot/MC issue.
Since 1.13 command selectors @p do not work in Spigot/Plugin commands, only Minecraft commands.

oh okay, thank you for your answer

@Killance did you try with simple commands like /test without arguments ?

Yes, a /test command without any arguments works fine

@Killance that's good thinking you got there - but think about this: do any other plugins use the target selectors like @p or @s etc? They don't - with a few exceptions. And those exceptions would've had to recreate those target selectors for themselves.

That's what you'd have to do aswell. The input arguments need to be handled within your custom commands. :)

You could do it like this however:

command /test <text>:
    trigger:

        arg 1 = "@p":

            (command sender).getBlock() is set
            set {_location} to (command sender).getBlock().getLocation()

            loop all players:

                loop player's world = {_location}'s world

                if {_closest-player} is not set:
                    set {_closest-player} to loop-player
                else if (distance between loop-player and {_location}) < (distance between {_closest-player} and {_location}):
                    set {_closest-player} to loop-player

        {_closest-player} is set
        send "&aYou're @p!" to {_closest-player}

Unfortunately this requires the usage of skript-mirror to work. Maybe a good opportunity to get/learn it, if you haven't already. :)

that's good thinking you got there - but think about this: do any other plugins use the target selectors like @p or @s etc? They don't - with a few exceptions. And those exceptions would've had to recreate those target selectors for themselves.

This isn't true. Bukkit offers a static selectEntities which can return entities from a target selector for you, found here. It's easy to use and implement into plugins; the only reason other plugins might not do it is because they haven't bothered.

Oh that's really cool - thanks for pointing that out!

I don't know how implementation of this would work or how doable it is. It might just be something simple we're missing but it's a larger consideration.

Definitely possible for 1.14+, but unfortunately the relevant code is not... exactly readable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Romitou picture Romitou  路  3Comments

Misio12320 picture Misio12320  路  3Comments

ghost picture ghost  路  3Comments

wohahobg picture wohahobg  路  3Comments

dhgameryt picture dhgameryt  路  3Comments