Skript: skripts in command blocks?

Created on 6 Sep 2018  路  24Comments  路  Source: SkriptLang/Skript

Spigot 1.13.1
Skript 2.3-alpha2

Most plugin commands can be executed in command blocks, but I cannot get a script to run. Is it possible?

bug completed medium

All 24 comments

Scripts arent commands. Scripts can create commands though. You should be able to use commands made by scripts in command blocks.

Note that @ selectors may not work with plugin commands in command blocks.

does it work if you prefix the command with skript:?

Already command blocks can use Skript commands, they can also run effect commands.

Because it is just console lol, @ selectors will work too.

The Skript command is:

command /starve:
        description: Starve player
        permission: blackdog.starve
        # permission message: &4You don't have permission to run this command!
        usage: /starve
        trigger:
...

I am able to insert

skript:skript starve

into a command block. But nothing happens if I trigger it. (To verify that the command block fires, I placed another after it in the chain; the second block fires.) If I run the command manually, it works as expected.

Any command that works in the server console will work on command blocks, that script also works for me. Adding skript: doesn't change anything. Skript 2.2-dev37c Paper 1.12.2

But let me try 1.13.1

Edit: Didn't work on 1.13.1 lol, weird. The command works in the server console but doesn't work on a command block. But effect commands still work.

@Blueyescat this is about 1.13 though, if something changed on how commands are handled (something I doubt but who knows), we gotta fix it.

Once somebody is on the issue, make sure that Skript commands still work with Bukkit.dispatchCommand too

the way commands work was very clearly changed. I remember one of the shapshots, you could use vannila server commands (eg. /ban, /kick) in singleplayer worlds. 1.13 has so many changes to so many things, its insane

@LeotomasMC Both /ban and /kick have been commands in vanilla Minecraft since early alpha. Those aren't new nor have they ever been exclusive to Bukkit or something.

That being said, yes, 1.13 has an entirely new command parser called Brigadier so that could be in part the cause of this issue if it is legitimate.

@TheBentoBox But in single player, even /reload lol.

Reload was added in 1.12

I was talking about this https://www.youtube.com/watch?v=UKsGQmkZvGU but now i tried it in 1.13.1 and didn't work 馃

Mojang's on to us

Could someone test again? 2.3-beta1 introduced some hacks to work with Brigadier.

Works fine! 馃帀

Spigot 1.13.1
Skript 2.3-beta1

I have not been able to get it to work. How exactly should the command be specified in the commandblock. I tried:

  • starve
  • skript starve

I tried:

skript:starve

It is recognized in the commandblock, tab-completion. It just doesn't execute.

Code, please

Command is

skript:starve

Skript is

command /starve:
        description: Starve player
        usage: /starve
        trigger:
                set {_player} to the player

                subtract 0.5 from hunger of {_player}
                set {_hunger} to hunger of {_player}

                set {_message} to ""
                if {_player} is in world "world_lobby":
                        if {_hunger} is 9:
                                set {_message} to "Aren't you getting hungry? Eat some cake!"
                        if {_hunger} is 8:
                                set {_message} to "You don't like cake?"
                        if {_hunger} is 7:
                                set {_message} to "Cake is soooooooo good!"
                        if {_hunger} is 6:
                                set {_message} to "We're out of cholocate cake. Try the red velvet!"
                        if {_hunger} is 5:
                                set {_message} to "Cake is health food!"
                        if {_hunger} is 4:
                                set {_message} to "You'll be sorry if you don't eat some cake!"
                        if {_hunger} is 3:
                                set {_message} to "You're going to regret this!"
                        if {_hunger} is 2:
                                set {_message} to "Don't say I didn't warn you!"
                        if {_hunger} is 1:
                                set {_message} to "Eat some cake before you die!"
                        if {_hunger} is less than 1:
                                set {_message} to "Sorry about that!"
                        {_message} is not equal to ""
                        send message "%{_message}%" to {_player}
                        exit

I also tried a version with player set explicitly from arg 1, with the command

skript:starve %s

The result was the same.

How is the command block supposed to know what player to use? Excluding a target selector will definitely not work and %s isn't a valid target selector. You're probably thinking of @s but even then that wouldn't work because that targets the person executing the command, which is again the command block who is not a player. You'd need to add a player argument to the command and then send an actual player or a valid player selector as the argument to the command within the command block.

Of course I meant @s -- I mistyped. As mentioned above, I tried this version:

command /starve-player <player>:
        description: Starve player
        usage: /starve <player>
        trigger:
                set {_player} to arg 1

                subtract 0.5 from hunger of {_player}
                set {_hunger} to hunger of {_player}

                set {_message} to ""
                if {_player} is in world "world_lobby":
                        if {_hunger} is 9:
                                set {_message} to "Aren't you getting hungry? Eat some cake!"
                        if {_hunger} is 8:
                                set {_message} to "You don't like cake?"
                        if {_hunger} is 7:
                                set {_message} to "Cake is soooooooo good!"
                        if {_hunger} is 6:
                                set {_message} to "We're out of cholocate cake. Try the red velvet!"
                        if {_hunger} is 5:
                                set {_message} to "Cake is health food!"
                        if {_hunger} is 4:
                                set {_message} to "You'll be sorry if you don't eat some cake!"
                        if {_hunger} is 3:
                                set {_message} to "You're going to regret this!"
                        if {_hunger} is 2:
                                set {_message} to "Don't say I didn't warn you!"
                        if {_hunger} is 1:
                                set {_message} to "Eat some cake before you die!"
                        if {_hunger} is less than 1:
                                set {_message} to "Sorry about that!"
                        {_message} is not equal to ""
                        send message "%{_message}%" to {_player}
                        exit

starve-player playerName

works correctly from the command line in-game (or at the console). The commandblock command is

skript:starve-player @s

which does not appear to execute. The commandblock configuration is

  • Impulse
  • Unconditional
  • Needs Redstone

triggered by a button on top. There is no indication of execution, and no _previous output_ is produced in the commandblock.

So, I tested it with the exact same command, and I know what's happening now. Commands do work, what doesn't work is selectors in commands (though, in this specific case @s wouldn't have worked since the one who executed the command is the command block and not a player), this is a rather different bug that was reported before too.

Yeah, @s is the wrong target selector there. That makes the command target the one executing it. You'd be trying to starve the command block. Now, if the target selectors aren't working anyway, that's a different story, but you need to understand which target selectors to use when in the first place to use them properly. It's not often you need @s in command blocks.

OK, I understand the mistake. Thanks for guidance. I have moved the execution to a periodical skript, so (for me) the issue is moot.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

GiraffeCubed picture GiraffeCubed  路  3Comments

TrademarkTM picture TrademarkTM  路  4Comments

ghost picture ghost  路  3Comments

Snow-Pyon picture Snow-Pyon  路  4Comments