Skip to content

Language Overview

Mwexim edited this page Apr 10, 2021 · 4 revisions

Skript is a simple, intuitive, conventional scripting language made with Java.

  • Simple means that everyone can start using Skript right now and make valuable progress. No programming experience is required to start learning it: it is easy to pick up, fun to code loads of stuff with and will help you grow in understanding the programming basics.
  • How simple Skript may look at first glance, we want to preserve an intuitive code-base, so experienced developers have the right tools to develop whatever they prefer. You will find yourself at home while coding in Skript since it provides very similar functions to other simple languages like JavaScript and Python.
  • This all is preserved by making the language conventional. This means that there is no class-like structure to create your own types: all types are predetermined by the parser. However, other people can extend this parser using add-ons, so they can expand the functionality of Skript beyond its current limitations.

Hello World in Skript

The code block below will print in "Hello World" once loaded.

on script load:
    print "Hello World"

As you can witness, the code speaks for itself. If I'd show this to my grandma, she would still be able to understand what is going on. That's the power of Skript.

Basic types

Like each language, Skript has a set of basic types. We do not call them primitive types, because that is not what they are defined as. Skript types correspond to Java classes, the object type is the supertype.

Booleans

Booleans are either true or false. Skript provides alternatives like on/off and yes/no.

Integers and numbers

Integers are both negative and positive numbers with no decimals. There practically no limit on these integers, hence why there isn't an unsigned variant. Examples could be 100, 234 or -9999. You can use an underscore ('_') to format large numbers better, like 1_000_000.

Numbers can be all possible numbers, with technically an infinite amount of decimals. All integers are by definition numbers, but not the other way around. Examples are 1.03 and -234.567

One can perform numerical operations between different numbers.

5 + 3     # Sum of two numbers
27 - 13   # Difference between two numbers
2.07 * 3  # Product of two numbers
5 / 2     # Number division
2 ^ 3     # Exponentiation

Strings

Strings are used to express bits of text. All Unicode characters are supported and strings are formed very similarly to most other programming languages.

There are multiple possibilities to express a text:

  • "Hello World" is a normal string. Later on, we will see that you can use expressions and tags inside normal strings to change how your text actually looks.
  • 'Hello World' is a literal string. Unlike the normal string, a literal string is used to only represent the text inside. It is not possible to use expressions inside this string.

To concatenate certain values inside of strings, you can surround your non-string expression with %. The parser will recognise it and replace it with the output of that expression.

print "5 times 3 equals %5 * 3%" 
# would output "5 times 3 equals 15"

Side note: as you may have noticed, comments are started by the #-character and will not be parsed. If you still want to use hashtags in your code, double them.

Clone this wiki locally