Skript Syntax and Indentation Guide

Syntax is the way that code is read. Skript will look for certain things to figure out how to read the code. It is important that you know how this works so that all of your scripts will work the way they are supposed to. Different aspects of Skript's syntax are show below.

Indenting

on rightclick:
        block is a sign
        line 1 of clicked block is "[Checkpoint]"
        set {checkpoint.%player%} to location of player
        message "Progress saved!"

on respawn:
        if {checkpoint.%player%} is not set:
                stop trigger
        wait 3 seconds
        teleport player to {checkpoint.%player%}

All indents tell Skript when to do something. 'On rightclick:' is an event that triggers when a player right clicks, and then runs all the code indented under it. An indent is either one tab or a fixed amount of spaces. You can only use one or the other for the entire script. You can however use tabs in one script and spaces in another, they just have to be different files. I prefer to use tabs, because they are quicker and only require 1 tap of the key per indent. Also note that when you copy paste scripts it will paste them as spaces. So if you copy part of your script and typed te rest with tabs, you will have to change them to all tabs or spaces. Examples of when to indent and how many there should be are below:

Commands

command /commandname <args>:
        description: This is an example command
        permission: skript.permission
        usage: /commandname <args>
        trigger:
                effects and conditionals go here

When you start any event, you start with no indents. Every time after that you will usually indent every time after you use a colon. Commands are the only exception. At the end of your command and arguments you put in a colon to signify that you are done with that line and can continue on. You indent after the colon like normal. Then you add things like description, permission and usage to the command. Even though these have a colon after them, you do not indent. When you have added all that you would like to your commands here and are ready to add its effects, you type "trigger:" Now you are past the only irregularity and can indent after each colon, which includes the one you just put after 'trigger'. Now you can add effects and conditionals.

Conditionals

Any time you use a conditional you can put a colon at the end of it. This will require you to indent, but allow you to separate out the effects. An example is shown below:

on rightclick:
        player has permission "skript.example":
                strike lightning at targeted block
        else:
                strike lightning effect at targeted block

If the player has the correct permission, the code under the conditional will be executed, in this case, striking lighting at the block the player is looking at. The else, means that if the previous conditional that used a colon was false, then do this instead. NOTE: You can have conditionals inside of other conditionals indenting one more each time.

When you are done with a section then indent one less to return to the previous grouping.

Remember if you have any questions, to search the help forum as it may have already been answered! http://dev.bukkit.org/server-mods/skript/forum/help/

-Demon