Tutorial by: WhoCutTheCheese

Howdy all, today I'm going to show you some simple debugging steps you should take before seeking help!
Knowing how to debug is extremely important, and it is something every developer must do.

What is debugging?

Good question! Debugging is the process of testing bits of code to find a non-working part, and why it's not working.
If you have a large chunk of code, and something isn't working quite right, then you'll probably want to debug it!

How do I debug?

Well, debugging is actually pretty simple, but there are a few different methods to go about it!

The most common form of debugging is by sending messages to yourself. For example, you typed in the wrong variable name and you're not sure why it isn't working, you can send the variable to yourself and ensure things are correct.

# Example of how to debug code, not necessarily best practice, but this is for an example

command /broadcast [<text>]:
        set {_msg} to arg-1
        broadcast "%{_message}%"

I'm sure you all see the issue here, but indulge me. Say you try the command and you just can't see what's wrong with it.

Well you can always try logging the variable, to make sure it's set correctly.

command /broadcast [<text>]:
        set {_msg} to arg-1
        send {_msg} to player
        broadcast "%{_message}%"

And you see by debugging it that the variable is being set, so that leaves only one other explanation, you mistyped in the variable name!

Wasn't that easy?

Final thoughts

Easily sending messages to yourself, or console is the most versatile way to debug, it makes it so easy to figure things out, especially in Skript! If you're unsure about anything, there's a good chance that sending it to yourself will help.

Hopefully this helped you figure out errors better! And this is my first tutorial, so if I missed anything important, or am just wrong about anything, feel free to leave a comment.

Did you find WhoCutTheCheese's tutorial helpful?

You must be logged in to comment