Skript Reader is an open-source library made to interpret the component types of Skript codes recursively, in order to provide an easy implementation for syntax markup and obfuscation. This library is mainly used in the development of Skript Studio and Skript Obfuscator.
The demo of the library could be accessed in Skript Studio.
- Divide single-line script into comprehensive components.
- Provides both nested and collapsed export structure.
- Interpret structure by general syntax, adapt to all add-on format.
npm install skript-reader
const skript_reader = require("skript-reader");
const script = "send \"hello %display_name({_uuid::%player%})%\" to {_players::*} #this is an example";
try {
// prints nested structure
const elements_nested = skript_reader(script);
console.log(elements_nested);
// prints collapsed structure
const elements_collapsed = elements_nested.collapse_components();
console.log(elements_collapsed);
} catch (error) {
// prints syntax error (for example string not properly enclosed)
console.log(error.toString());
}
Type | Description | Example |
---|---|---|
body |
||
string |
enclosed string literals | "hello world" |
number |
decimal numbers (base 10) |
10.5 |
boolean |
boolean values (true / false) |
true |
expression |
general expression statements | %player's name% |
variable |
enclosed variables | {_player} |
function |
function statements (declare / access) |
world() |
indention |
script line indention (tabs / spaces) |
|
comment |
script comments | # TODO: fix bug |
function_parameter |
||
function_parameter_name |
function parameter name | login(username : string = "anonymous") |
function_parameter_type |
function parameter object type | login(username: string = "anonymous") |
function_parameter_default |
function parameter default object | login(username: string = "anonymous" ) |
Skript Reader supports exporting the components in both nested and collapsed structures, try clicking on any of the following collapsible sections to view them.
Nested Result (Click to Expand)
{
"object_content": "send \"hello %display_name({_uuid::%player%})%\" to {_players::*} #this is an example",
"object_depth": 0,
"parent_types": [],
"object_type": "body",
"inner_components": [
{
"object_content": "send ",
"object_depth": 1,
"parent_types": [],
"object_type": "body",
"inner_components": []
},
{
"object_content": "\"hello %display_name({_uuid::%player%})%\"",
"object_depth": 1,
"parent_types": [ "body" ],
"object_type": "string",
"inner_components": [
{
"object_content": "\"hello ",
"object_depth": 2,
"parent_types": [ "body" ],
"object_type": "string",
"inner_components": []
},
{
"object_content": "%display_name({_uuid::%player%})%",
"object_depth": 2,
"parent_types": [ "body", "string" ],
"object_type": "expression",
"inner_components": [
{
"object_content": "%",
"object_depth": 3,
"parent_types": [ "body", "string" ],
"object_type": "expression",
"inner_components": []
},
{
"object_content": "display_name({_uuid::%player%})",
"object_depth": 3,
"parent_types": [ "body", "string", "expression" ],
"object_type": "function",
"inner_components": [
{
"object_content": "display_name(",
"object_depth": 4,
"parent_types": [ "body", "string", "expression" ],
"object_type": "function",
"inner_components": []
},
{
"object_content": "{_uuid::%player%}",
"object_depth": 4,
"parent_types": [ "body", "string", "expression", "function" ],
"object_type": "variable",
"inner_components": [
{
"object_content": "{_uuid::",
"object_depth": 5,
"parent_types": [ "body", "string", "expression", "function" ],
"object_type": "variable",
"inner_components": []
},
{
"object_content": "%player%",
"object_depth": 5,
"parent_types": [ "body", "string", "expression", "function", "variable" ],
"object_type": "expression",
"inner_components": []
},
{
"object_content": "}",
"object_depth": 5,
"parent_types": [ "body", "string", "expression", "function" ],
"object_type": "variable",
"inner_components": []
}
]
},
{
"object_content": ")",
"object_depth": 4,
"parent_types": [ "body", "string", "expression" ],
"object_type": "function",
"inner_components": []
}
]
},
{
"object_content": "%",
"object_depth": 3,
"parent_types": [ "body", "string" ],
"object_type": "expression",
"inner_components": []
}
]
},
{
"object_content": "\"",
"object_depth": 2,
"parent_types": [ "body" ],
"object_type": "string",
"inner_components": []
}
]
},
{
"object_content": " to ",
"object_depth": 1,
"parent_types": [],
"object_type": "body",
"inner_components": []
},
{
"object_content": "{_players::*}",
"object_depth": 1,
"parent_types": [ "body" ],
"object_type": "variable",
"inner_components": []
},
{
"object_content": " ",
"object_depth": 1,
"parent_types": [],
"object_type": "body",
"inner_components": []
},
{
"object_content": "#this is an example",
"object_depth": 1,
"parent_types": [ "body" ],
"object_type": "comment",
"inner_components": []
}
]
}
Collapsed Result (Click to Expand)
[
SkriptObject {
object_content: 'send ',
object_depth: 1,
parent_types: [],
object_type: 'body',
inner_components: []
},
SkriptObject {
object_content: '"hello ',
object_depth: 2,
parent_types: [ 'body' ],
object_type: 'string',
inner_components: []
},
SkriptObject {
object_content: '%',
object_depth: 3,
parent_types: [ 'body', 'string' ],
object_type: 'expression',
inner_components: []
},
SkriptObject {
object_content: 'display_name(',
object_depth: 4,
parent_types: [ 'body', 'string', 'expression' ],
object_type: 'function',
inner_components: []
},
SkriptObject {
object_content: '{_uuid::',
object_depth: 5,
parent_types: [ 'body', 'string', 'expression', 'function' ],
object_type: 'variable',
inner_components: []
},
SkriptObject {
object_content: '%player%',
object_depth: 5,
parent_types: [ 'body', 'string', 'expression', 'function', 'variable' ],
object_type: 'expression',
inner_components: []
},
SkriptObject {
object_content: '}',
object_depth: 5,
parent_types: [ 'body', 'string', 'expression', 'function' ],
object_type: 'variable',
inner_components: []
},
SkriptObject {
object_content: ')',
object_depth: 4,
parent_types: [ 'body', 'string', 'expression' ],
object_type: 'function',
inner_components: []
},
SkriptObject {
object_content: '%',
object_depth: 3,
parent_types: [ 'body', 'string' ],
object_type: 'expression',
inner_components: []
},
SkriptObject {
object_content: '"',
object_depth: 2,
parent_types: [ 'body' ],
object_type: 'string',
inner_components: []
},
SkriptObject {
object_content: ' to ',
object_depth: 1,
parent_types: [],
object_type: 'body',
inner_components: []
},
SkriptObject {
object_content: '{_players::*}',
object_depth: 1,
parent_types: [ 'body' ],
object_type: 'variable',
inner_components: []
},
SkriptObject {
object_content: ' ',
object_depth: 1,
parent_types: [],
object_type: 'body',
inner_components: []
},
SkriptObject {
object_content: '#this is an example',
object_depth: 1,
parent_types: [ 'body' ],
object_type: 'comment',
inner_components: []
}
]