HyperScript
Docs

How do I...?

Short scripts for things nearly every server wants. Each one works as it stands: copy it into a file in the scripts folder, or press Try it to open it in the Playground and change it there.

A kit once a day

A command that gives items, and makes each player wait a day before it works for them again.

command /kit:
    description: Get the starter kit
    cooldown: 1 day
    cooldown message: "&cYou can have the kit again in %cooldown%."
    trigger:
        give player 1 stone sword
        give player 16 bread
        give player 32 torch
        send "&aHere is your kit. Come back tomorrow."

A home to go back to

/sethome remembers where a player stands; /home takes them there.

command /sethome:
    trigger:
        set {%player%.home} to player's location
        send "&aHome set."

command /home:
    cooldown: 10 seconds
    trigger:
        if {%player%.home} is not set:
            send "&cYou have no home yet. Stand where you want it and type /sethome."
            reset cooldown
            stop
        teleport player to {%player%.home}
        send "&7Welcome home."

Warps anybody can use

An operator makes a warp where they stand; everybody can go to it, and Tab offers the names.

command /setwarp <name>:
    permission: op
    trigger:
        set {warp.%arg.1%} to player's location
        if not ({warps} contains arg.1):
            append arg.1 to {warps}
        send "&aWarp %arg.1% set."

command /warp [name]:
    tab complete: {warps}
    trigger:
        if arg.1 is not set:
            send "&7Warps: &f%{warps}%"
            stop
        if {warp.%arg.1%} is not set:
            send "&cThere is no warp called %arg.1%."
            stop
        teleport player to {warp.%arg.1%}
        send "&7You are at &f%arg.1%&7."

Coins for every kill

A player who kills a monster gets a coin, and /coins says how many they have.

on entity death:
    if killer is set:
        add 1 to {%player%.coins}
        send action bar "&6+1 coin" to player

command /coins:
    trigger:
        set {_coins} to {%player%.coins} + 0
        send "&7You have &6%{_coins}% coins&7."

Nobody breaks blocks at spawn

Breaking and placing blocks is stopped within 30 blocks of a place you choose.

command /setspawnguard:
    permission: op
    trigger:
        set {spawnguard} to player's location
        send "&aBlocks within 30 blocks of here are protected."

on block break:
    if {spawnguard} is set:
        if distance between event's location and {spawnguard} < 30:
            if player does not have permission "spawn.build":
                cancel event
                send action bar "&cYou cannot break blocks here." to player

on block place:
    if {spawnguard} is set:
        if distance between event's location and {spawnguard} < 30:
            if player does not have permission "spawn.build":
                cancel event

A tip in chat every few minutes

One line out of a list is shown to everybody every five minutes.

every 5 minutes:
    set {_tips} to ["&7Type &f/kit &7for a starter kit.", \
                  "&7Set a home with &f/sethome&7.", \
                  "&7Found a bug? Tell an admin."]
    set {_tip} to random item of {_tips}
    broadcast "&8[&bTip&8] %{_tip}%"

Welcoming somebody new

Everybody is told when a player joins for the first time, and the new player gets a few things.

on player join:
    if {%player%.seen} is not set:
        set {%player%.seen} to true
        broadcast "&d%player.name% &7is new here. Say hi!"
        give player 8 bread
        send "&aWelcome! Here is something to eat."
    else:
        send "&7Welcome back, &f%player.name%&7."

Hills made of noise

A noise generator gives every place a number between 0 and 1 that changes smoothly, which is what hills are made of.

command /hills:
    permission: op
    trigger:
        set {_hills} to noise generator "perlin" with seed 42 and scale 24 and octaves 3
        loop 16 times:
            set {_x} to x of player's location + loop-number
            loop 16 times:
                set {_z} to z of player's location + loop-number
                set {_height} to round(noise of {_hills} at {_x}, {_z} * 12)
                set block at {_x}, y of player's location + {_height}, {_z} to stone
        send "&aHills made."