HyperScript
Docs

← All of the Docs Commands and events

Commands

structuretrigger:

yes · The code to run

command /pay <target:player> <amount:number> [note]:
    players only: true
    trigger:
        subtract arg.2 from {%player%.coins}
        add arg.2 to {%arg.1%.coins}
Try it
structurepermission:

no · Permission node needed to run the command, or op for server operators only

command /heal:
    description: Restore your health
    usage: /heal [player]
    permission: demo.heal
    permission message: "&cYou cannot use /heal."
    aliases: h, mend
    trigger:
        execute console command "effect give %player.name% minecraft:instant_health 1 10"
        send "&aHealed."
Try it
structurepermission message:

no · Shown to players who lack the permission

command /heal:
    description: Restore your health
    usage: /heal [player]
    permission: demo.heal
    permission message: "&cYou cannot use /heal."
    aliases: h, mend
    trigger:
        execute console command "effect give %player.name% minecraft:instant_health 1 10"
        send "&aHealed."
Try it
structureusage:

no · Usage text shown in /help

command /heal:
    description: Restore your health
    usage: /heal [player]
    permission: demo.heal
    permission message: "&cYou cannot use /heal."
    aliases: h, mend
    trigger:
        execute console command "effect give %player.name% minecraft:instant_health 1 10"
        send "&aHealed."
Try it
structuredescription:

no · Description shown in /help

command /heal:
    description: Restore your health
    usage: /heal [player]
    permission: demo.heal
    permission message: "&cYou cannot use /heal."
    aliases: h, mend
    trigger:
        execute console command "effect give %player.name% minecraft:instant_health 1 10"
        send "&aHealed."
Try it
structurealiases:

no · Comma-separated alternative names

command /heal:
    description: Restore your health
    usage: /heal [player]
    permission: demo.heal
    permission message: "&cYou cannot use /heal."
    aliases: h, mend
    trigger:
        execute console command "effect give %player.name% minecraft:instant_health 1 10"
        send "&aHealed."
Try it
structurecooldown:

no · How long each player must wait between uses, e.g. 30 seconds

on right click:
    cooldown: 2 seconds
    send "&7Click!"
Try it
structurecooldown message:

no · Shown to a player who is still waiting; %cooldown% is the time left

command /kit:
    cooldown: 1 hour
    cooldown message: "&cYou must wait %cooldown% before using this again!"
    trigger:
        give 1 diamond to player
Try it
structurewarmup:since 1.7.60

no · How long a player has to stand still before the trigger runs, e.g. 3 seconds, with the time counting down above the hotbar. Moving or being hurt calls it off. The console does not wait

command /spawn:
    warmup: 3 seconds
    trigger:
        teleport player to {spawn}
Try it
structurecost:since 1.7.60

no · What running the command costs: 100 of the server's money (with Vault and an economy plugin), or 5 gems of a currency of the script's own. Somebody who has not got it is told so and the trigger does not run; otherwise it is taken first

command /heal:
    cost: 50
    trigger:
        heal player
        send "&aHealed."
Try it
structurecost message:since 1.7.60

no · What they are told then; %cost% is the cost as written

command /feed:
    cost: 20
    cost message: "&cFood costs %cost% coins."
    trigger:
        feed player
Try it
structureworlds:since 1.7.64

no · The worlds the command works in: worlds: "survival", "resource". Somewhere else the player is told so and the trigger does not run. The console is let through

command /mine:
    worlds: "survival", "resource"
    trigger:
        give 1 iron pickaxe to player
Try it
structureworlds message:since 1.7.64

no · What they are told then

command /arena:
    worlds: "minigames"
    worlds message: "&cThe arena is in the minigames world."
    trigger:
        send "&aWelcome to the arena."
Try it
expressiontab complete: <list>since 1.7.1

no · What Tab offers for the first argument; tab complete 2: for the second, and so on

command /warp <name>:
    tab complete: keys of {warp}
    trigger:
        teleport player to {warp.%arg.1%}
Try it
expressiondisabled: truesince 1.7.1

no · Keep the command in the file without adding it to the server

command /beta:
    disabled: true
    trigger:
        send "&7Not ready yet."
Try it
structuresubcommand <name>:since 1.7.1

no · A command inside the command, with options and a trigger of its own

command /team:
    subcommand join <red|blue>:
        trigger:
            add player to team arg.1
    subcommand leave:
        trigger:
            remove player from team
Try it
expressionplayers only: truesince 1.7.0

no · The console is told it cannot use the command. players only: alone says the same

command /sethome:
    players only: true
    trigger:
        set {%player%.home} to player's location
Try it
expressionconsole only: truesince 1.7.0

no · Players are told they cannot use the command

command /maintenance:
    console only: true
    trigger:
        set {maintenance} to true
Try it
expression<onsince 1.5.7

off>, <red · blue · green>` · Those words

send "&eUsage: /event <on|off>"
Try it
structure<player> or <target>since 1.5.7

The players who are online

command /greet <player>:
    trigger:
        send "&aHello from %player.name%!" to arg.1
Try it
expression<name:player>since 1.7.0

Must be someone who is online; Tab offers their names

command /greet <target:player>:
    trigger:
        send "&aHello!" to arg.1
Try it
expression<name:number>since 1.7.0

Must be a number

command /setprice <price:number>:
    trigger:
        set {price} to arg.1
Try it
expression<name:integer>since 1.7.0

Must be a whole number. Both kinds of number may be typed short, 1.5k or 2m, and reach the trigger written out

command /roll <sides:integer>:
    trigger:
        send "&7You rolled " + random integer between 1 and arg.1
Try it
expression<name:duration>since 1.7.59

Must be a length of time: 30s, 10m, 2h, 1h30m, or a bare number of seconds. In the trigger the argument is that many seconds, so it goes wherever a time does: mute arg.1 for arg.2

command /slow <target:player> <time:duration>:
    permission: "staff.slow"
    trigger:
        set {%arg.1%.slowed} to true for arg.2
        send "&7%arg.1% is slowed."
Try it
expression<name:boolean>since 1.7.59

true, yes or on, or false, no or off; in the trigger it is true or false. Tab offers the two

command /pvp <on:boolean>:
    permission: "staff.pvp"
    trigger:
        set {pvp} to arg.1
        send "&7PvP: &f%arg.1%"
Try it
expression<name:item>since 1.7.59

Must be the name of an item of the game, as in diamond_sword

command /gimme <what:item>:
    permission: "staff.gimme"
    trigger:
        send "&7You asked for &f%arg.1%&7."
Try it
expression<name:world>since 1.7.59

Must be a world that is loaded; Tab offers their names

command /daytime <where:world>:
    permission: "staff.time"
    trigger:
        set time in world arg.1 to 1000
Try it
expression<name:offline player>since 1.7.59

Must be somebody who has played here, online or not

command /seen <who:offline player>:
    trigger:
        send "&7%arg.1% was last on &f%last seen of arg.1%"
Try it
expression<name:text>since 1.7.59

Everything from there to the end of the line as one argument, spaces and all. It has to be the last one

command /announce <words:text>:
    permission: "staff.announce"
    trigger:
        send "&6[!] &f%arg.1%" to all players
Try it
expression<onsince 1.5.7

off>` · One of the words, and nothing else: anything other is answered with the usage

send "&eUsage: /event <on|off>"
Try it
expression[name:type]since 1.7.0

In square brackets: may be left out, but is checked when given

command /heal [target:player]:
    trigger:
        if arg.1 is set:
            heal arg.1
        else:
            heal player
Try it
expression[name:type = value]since 1.7.58

What the argument is when it is left out: with [amount:number = 1], arg.2 is 1 for a player who gave no amount. Works without a type as well, [note = "a gift"]. Only arguments at the end are filled in

command /coins [amount:number = 1]:
    trigger:
        add arg.1 to {%player%.coins}
        send "&a+%arg.1% coins"
Try it
Guide and examples
command /heal:
    description: Restore your health
    usage: /heal [player]
    permission: demo.heal
    permission message: "&cYou cannot use /heal."
    aliases: h, mend
    trigger:
        execute console command "effect give %player.name% minecraft:instant_health 1 10"
        send "&aHealed."
OptionRequiredMeaning
trigger:yesThe code to run
permission:noPermission node needed to run the command, or op for server operators only
permission message:noShown to players who lack the permission
usage:noUsage text shown in /help
description:noDescription shown in /help
aliases:noComma-separated alternative names
cooldown:noHow long each player must wait between uses, e.g. 30 seconds
cooldown message:noShown to a player who is still waiting; %cooldown% is the time left
warmup:noHow long a player has to stand still before the trigger runs, e.g. 3 seconds, with the time counting down above the hotbar. Moving or being hurt calls it off. The console does not wait
cost:noWhat running the command costs: 100 of the server's money (with Vault and an economy plugin), or 5 gems of a currency of the script's own. Somebody who has not got it is told so and the trigger does not run; otherwise it is taken first
cost message:noWhat they are told then; %cost% is the cost as written
worlds:noThe worlds the command works in: worlds: "survival", "resource". Somewhere else the player is told so and the trigger does not run. The console is let through
worlds message:noWhat they are told then
tab complete: <list>noWhat Tab offers for the first argument; tab complete 2: for the second, and so on
disabled: truenoKeep the command in the file without adding it to the server
subcommand <name>:noA command inside the command, with options and a trigger of its own
players only: truenoThe console is told it cannot use the command. players only: alone says the same
console only: truenoPlayers are told they cannot use the command

A number within limits. An argument that is a number can say what it has to lie between: <amount:number 1 to 10000>, <level:integer at least 1>, [percent:number at most 100]. A player who gives another number is told amount must be between 1 and 10000. and the trigger does not run.

command /pay <target:player> <amount:number 1 to 10000>:
    trigger:
        subtract arg.2 from {%player%.coins}
        add arg.2 to {%arg.1%.coins}
        send "&aYou paid %arg.1% %money(arg.2)%."

The command line may describe its arguments after the name, as in command /pay <player> <amount>:. It becomes the usage text unless a usage: line is given, and it decides what pressing Tab offers while the command is typed:

Written in the headerTab offers
`<onoff>, <redbluegreen>`Those words
<player> or <target>The players who are online
Anything else, such as <amount>Nothing

Subcommands. A command with several jobs can give each one its own block instead of a switch on the first argument. Each subcommand has its own permission, description, checked arguments and trigger, and arg.1 inside it is the first word *after* its name:

command /warp <name>:
    tab complete: keys of {warp}
    trigger:
        teleport player to {warp.%arg.1%}
    subcommand set <name>:
        permission: "warps.manage"
        trigger:
            set {warp.%arg.1%} to player's location
            send "&aWarp %arg.1% set."
    subcommand list:
        trigger:
            send "&7Warps: &f" + join keys of {warp} with ", "
  • /warp set base runs the set block; /warp base runs the command's own trigger.
  • A command may consist of subcommands only. Used without one, it answers with their names.
  • Tab offers the subcommands a player is allowed to use, then each one's own arguments.
  • tab complete: takes any list and is worked out when Tab is pressed, so it can offer warp names, team names or anything else a script keeps.

What Tab offers, argument by argument. tab complete: can also be a block. Its lines run each time Tab is pressed, and set arg.1 to ... in it says what is offered for the first argument, set arg.2 to ... for the second, and so on. The lines are ordinary code, so what is offered for one argument can depend on what was typed for the ones before it:

command /rank [action] [target] [rank]:
    permission: "ranks.admin"
    tab complete:
        set arg.1 to "set", "remove", "list"
        set {_online} to server.players
        if arg.1 is "set" or arg.1 is "remove":
            set arg.2 to {_online}
        if arg.1 is "set":
            set arg.3 to "owner", "admin", "moderator", "vip"
    trigger:
        send "&7You typed: %args%"

What stands after to may be values written one after the other, a list, or both.

  • Typing /rank and pressing Tab offers set, remove and list; after /rank set Steve it offers the ranks; after /rank list nothing, because the block set nothing for that.
  • An argument the block says nothing about is offered what the command's header says: the players who are online for <player>, the words of <on|off>.
  • Only what begins with what has been typed so far is shown, whatever the capitals.
  • The block runs on every press of Tab, so keep it to working out what to offer. It is not the place to send messages or change variables.
  • Outside this block an argument cannot be set: in a trigger arg.1 is what was typed.

Checked arguments. Give an argument a type and HyperScript checks it before the trigger runs, answering with what is wrong, and the usage line for a missing argument or a number that is not one:

command /pay <target:player> <amount:number> [note]:
    players only: true
    trigger:
        subtract arg.2 from {%player%.coins}
        add arg.2 to {%arg.1%.coins}
Written in the headerChecked
<name:player>Must be someone who is online; Tab offers their names
<name:number>Must be a number
<name:integer>Must be a whole number. Both kinds of number may be typed short, 1.5k or 2m, and reach the trigger written out
<name:duration>Must be a length of time: 30s, 10m, 2h, 1h30m, or a bare number of seconds. In the trigger the argument is that many seconds, so it goes wherever a time does: mute arg.1 for arg.2
<name:boolean>true, yes or on, or false, no or off; in the trigger it is true or false. Tab offers the two
<name:item>Must be the name of an item of the game, as in diamond_sword
<name:world>Must be a world that is loaded; Tab offers their names
<name:offline player>Must be somebody who has played here, online or not
<name:text>Everything from there to the end of the line as one argument, spaces and all. It has to be the last one
`<onoff>`One of the words, and nothing else: anything other is answered with the usage
[name:type]In square brackets: may be left out, but is checked when given
[name:type = value]What the argument is when it is left out: with [amount:number = 1], arg.2 is 1 for a player who gave no amount. Works without a type as well, [note = "a gift"]. Only arguments at the end are filled in

An argument without a type is not checked, as before. The types are not shown in the usage line.

A command declared without any arguments keeps the server's default, which is player names. The arguments are still read with %arg.1%, %arg.2% and so on, and are not checked for you.

A short command can also simply use a switch on the first argument, without subcommand blocks:

command /kit <starter|food>:
    trigger:
        switch arg.1:
            case "starter":
                give 1 stone sword to player
            case "food":
                give 16 bread to player
            default:
                send "&eUsage: /kit <starter|food>"

Commands can be run from the console; there is then no player. players only: true keeps the console out, or test if player is not set: yourself.