SkriptTips and Techniques

Skript - Reading Syntax and Debugging Code

1c71c7

1c7

2 min read
Skript - Reading Syntax and Debugging Code

In this blog post, we will discuss how to read syntax from the documentation, and how to debug your code.

First off, what is Documentation?

As Skript is a widely used plugin, many different websites have been set up dedicated to providing all the different syntaxes Skript has. A personal favourite of mine are the SkriptHub Docs. Here, you can find all of vanilla Skript's syntaxes and tons more of Addon's syntaxes too.

How to Read Syntax.

The syntax is a vital part of how you write your code. Syntax is basically the format your code must follow in order for it to work.

  • [optional] - Text in square brackets like this is optional, meaning it doesn't need to be present for the syntax to still be right.
  • (option one | option two) - Text in normal brackets and split with a line like this is a choice, meaning you can pick which one to use, however you must pick only one.
  • %strings% - Text wrapped in percentage signs is essentially just user input. There are a few different types, such as %player% or %object%, and the input must be of the required type (however, object can be any type).

Example

[the] (amount|number|size) of %objects%

In this example, as the the is in square brackets, it is optional, and does not need to be there for the code to still work. Furthermore, amount|number|size is in normal brackets, meaning a choice has to be made. The code will work the same with any of these chosen (please note that only one can be added). The word of is not surrounded by anything, meaning it is mandatory, and must be there. %objects% is now asking for user input. In this case, it can be anything, ranging from %all players% to a list variable such as {banned-players::*}. As the syntax is plural, our input must also be a plural (e.g. more than one).

Based on this, the syntax can be written many ways and still function the same:

the amount of all players
number of all players
the size of all players

How to Debug your Code.

Everyone makes mistakes, and learning how to properly debug your code will be essential in your journey of learning Skript.

Step 1: Errors - If your code has any errors when you reload it, the first thing you must do is read the error. Reading the error will usually give you everything you need, as it gives you the line number and what actually errors.

Step 2: Documentation - Once you have read your error and revisited the line of code that doesnt work, you should search up what you're trying to do on a documentation website, such as SkriptHub.

Step 3: Question - If you can't figure out what the issue is, it's probably time to ask someone else. Free Skript support is offered everywhere, for example the Minefort discord even has a dedicated #skript channel. There are also other discord servers such as skUnity that offers dedicated support. However, in order to get your query resolved, it's best you should form your question properly:

  • Include the code your working with.
  • Include any errors that you recieve.
  • Short and clearly, describe what your code should do.
  • Be patient and wait until someone helps.
Something wrong with this article? Reach out to me, @Adxm#9504, and we'll get it fixed!

Create your Minecraft server with Minefort.com

Elevate your Minecraft experience to new heights with Minefort - the most advanced and user-friendly server manager on the market, featuring a customizable control panel, a wide range of plugins and mods, and top-notch support from our team of experts!

Get started for free, no credit card required. 🎉