Skip to content

Skript Configuration

Pre-release
Pre-release
Compare
Choose a tag to compare
@Moderocky Moderocky released this 05 Feb 12:26
· 98 commits to master since this release

This draft contains a schema for Skript configuration .csk files.
In-memory readers/writers are included, as well as syntax for interacting with these from within Skript files.

The .csk file uses a raw key: value structure. Currently it supports only single-line string values, though in future more complex types (lists, sub-keys, etc.) should be supported.

key: value
my key: my value
another key: another value :)

Both line // and block /**/ comments are supported.
These are supported at a schema level and correctly attached to the following node.

// this comment belongs to 'key'
key: value

/*
this comment
belongs to 'my key'
*/
my key: my value

// this key
// has two comments attached!
another key: another value :)

Comments survive the loading/editing/saving process.

To use .csk files in Skript code, they can be referenced by literal path.

set {conf} to path/to/config.csk // this loads the data into memory
add "key: value" to {conf} // add pattern, for convenience
set "key" from {conf} to "value" // set pattern
// setting to 'null' is equivalent to deleting
save config {conf} // saves the in-memory version to its source file
delete path/to/config.csk // deletes the file

For utility, the file may also be used as a section header, which will automatically save it at the end of the section.

set {conf} to path/to/config.csk:
    add "key: value" to {conf}
    add "hello: there" to {conf}
// config is saved here