Basics of skript-yaml

This is only meant to cover the basics of skript-yaml. (Large font size used for accessibility purposes)

Starting out, What is skript-yaml?
Skript-Yaml is an addon for the Skript plugin that allows you to create, write in, read, remove from, and delete yaml/yml files using Skript-based syntax. This is important because it allows you to store information (without using variables or metadata tags), read information such as config files (without needing to use options in your script) and for removing that information once it is no longer necessary.

A yaml/yml file is a file written in YAML, suffixed with .yml or .yaml, YAML is a data serialization language designed to be easily readable and editable by humans without extensive knowledge of syntax and logic. While some will argue whether it is or isn't a markup language, it is often used for data storage and configuration files, which are the two main uses of skript-yaml.


Loading files
For the remainder of this document, I will refer to them as yml files and use the .yml prefix, as well as use yml in my skript examples. Using yaml is perfectly fine for all these things, I simply prefer "yml" over "yaml".

One of the most important syntaxes for yml with skript is the load effect. This effect lets you to create or pull information from a yml file. To do this, input load followed by the file path. If the referenced file does not exist, it will create it. For example:

on load: #when the skript is reloaded or server is restarted

load "/plugins/Skript/scripts/cosmetics/Config/config.yml"

#you can also format it like this, so that later you can refer to it using the name
#rather than the entire file path

load "/plugins/Skript/scripts/cosmetics/Config/config.yml" as "config"

You can use any file path, this is just an example from one of my skript files which had a config.
Now, let's say I add this into my config.yml

resetonrestart: true
#Multiple ways to format this information, either as a value or as a list. Lists and advanced stuff may be covered in a later tutorial
defaultmsg:
"Chicken wing"

Now, in my skript, I can do something like this
on load:
load "/plugins/Skript/scripts/cosmetics/Config/config.yml" as "config"
set {_d} to yml value "resetonrestart" from "config"
if {_d} = true:
broadcast "True"
else:
broadcast "False"

First I load the yml file, then I pull the value of the "resetonrestart" section and save it to a local variable so I don't have to call the long text a bunch of times in my skript. I would recommend using a RAM variable (deletes when server stops, if you don't have them enabled, you can enable them in the config or just delete the variable you use on unload).

You can then, for example, use the resetonrestart value to know if you should disable everyone's cosmetics when the server restarts, to save variable space. Of course, you could always just store their cosmetic information into a yml file prefixed with the player's username (could also use IP or uuid. I recommend UUID because it changes the least often of the 3). You can also unload the files using a similar effect.


Writing into and removing from a yml file
To write information into a yml file, you would use the YAML expression, use of which looks like this.
command write:
trigger:
set yml value "brrr" from "config" to true
set yml value "Nyoom" from "config" to "Breeeeeee"
save yml "config"


(The command is just an example of an event where you would do this)
This expression also allows you to remove from a yml file. Don't forget to save it afterward!
command wipe:
trigger:
delete yml value "brr" from "config"
save yml "config"



Deleting yml files
This is the last thing I am going to cover. There are effects for bulk deleting such as
delete all yml from directory "/plugins/Skript/scripts/cosmetics/Config/" (deleting all the yml files in a folder)
or
delete all loaded yml from directory "/plugins/Skript/scripts/cosmetics/Config/" (for deleting only the ones you have loaded)

But there is also an effect for normal deleting, and it is very simple
delete yml "config"

Thank you all for reading, here is the documentation for some of the referenced things
Full skript-yaml documentation: https://skripthub.net/docs/?addon=skript-yaml
Documentation for deleting: https://skripthub.net/docs/?id=2549
Documentation for loading: https://skripthub.net/docs/?id=1525
Documentation for unloading: https://skripthub.net/docs/?id=1527
Documentation for the YAML expression: https://skripthub.net/docs/?id=1530