Skip to content

Commit 2d278d1

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 2aed50a + ad9eb7a commit 2d278d1

File tree

4 files changed

+556
-0
lines changed

4 files changed

+556
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,53 @@ For clarity: SkriptLang's Skript implementation will be referred to as 'original
3737

3838
Skript is designed to be beginner-friendly. Ideally, a user with no experience should be able to read Skript code and understand its function. All instructions are written in basic English, avoiding niche programming terms and symbols wherever possible.
3939

40+
## Using ByteSkript
41+
42+
ByteSkript provides **three** different executable Jar files for different purposes.
43+
44+
Running these for the first time will create special folders in the run directory.
45+
46+
| Name | Purpose |
47+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
48+
| `skript/` | <p>This is where you can write your script files, with the extension <code>.bsk</code>.<br>All <code>.bsk</code> files in this directory and its subfolders will be compiled/loaded.</p> |
49+
| `resources/` | <p>This is where you can put non-script files that you need in your output jar.<br>This is only used by the jar builder.</p> |
50+
| `compiled/` | <p>If you are compiling your scripts to <code>.class</code> or <code>.jar</code> files, the output will go here.<br>This folder is never emptied, so make sure to delete any old versions before re-compiling.</p> |
51+
52+
### SkriptLoader
53+
54+
This is the simplest resource, used for loading (and running) user-created script files.
55+
56+
Raw script files can be written and placed in the `skript/` folder. All scripts will be loaded internally, but no classes or jar files will be written.
57+
58+
The `on [script] load` event will be triggered for each script as an entry point.
59+
60+
{% hint style="success" %}
61+
The ByteSkript compilers, language specification and compile-time API are available in this resource, so advanced scripts may use dynamic loading to load extra skript code written at runtime!
62+
{% endhint %}
63+
64+
### SkriptClassCompiler
65+
66+
This resource is used for generating compiled JVM `.class` files for each script in the `skript/` folder. The classes produced by this are not directly executable, but may be useful for sharing and special loading.
67+
68+
The compiled scripts will **not** be loaded or run.
69+
70+
### SkriptJarBuilder
71+
72+
This resource builds an executable jar containing all of the user-created scripts, resources and the ByteSkript runtime (`skript` namespace and functions.)
73+
74+
\
75+
This output jar can be run with `java -jar JarName.jar` and is distributable - it does not need anything as a dependency.
76+
77+
When executing this jar, all scripts will be loaded and the `on [script] load` event will be triggered for each script as an entry point.
78+
79+
{% hint style="danger" %}
80+
The ByteSkript standard compiler and compile-time API are **not** added to the output jar.
81+
{% endhint %}
82+
83+
{% hint style="success" %}
84+
The dynamic function on-the-fly compiler **is** available in this jar, so dynamic function calls are available.
85+
{% endhint %}
86+
4087
## Language Libraries
4188

4289
Due to its fixed nature, the Skript language has always relied on third-party add-ons to add new syntax and functionality for specific areas.

SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* [Generic Effects](structures/effects/generic-effects.md)
2323
* [Expressions](structures/expressions/README.md)
2424
* [Variables](structures/expressions/variables.md)
25+
* [Simple Expressions](structures/expressions/simple-expressions.md)
26+
* [I/O Expressions](structures/expressions/i-o-expressions.md)
2527

2628
## namespaces
2729

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
description: >-
3+
A set of expressions related to input/output using files, streams, readers and
4+
sockets.
5+
---
6+
7+
# I/O Expressions
8+
9+
Some of these expressions are quite advanced and may be dangerous for beginners.
10+
11+
{% hint style="info" %}
12+
Accessing files can be quite slow as it relies on the machine's file system.
13+
14+
To avoid the program slowing down it may be preferable to access files on a background process.
15+
{% endhint %}
16+
17+
### File Expressions
18+
19+
`[a] new file at %String%`
20+
21+
Creates a new file at the given path. Returns that file object.
22+
23+
`[the] file at %String%`
24+
25+
Retrieves the existing file at the given path. Returns that file object. This may be `null` if the file does not exist.
26+
27+
`%File% is [a] file`
28+
29+
Whether the file is a file (not a folder.)
30+
31+
`%File% is [a] folder`
32+
33+
Whether the file is a folder (not a file.)
34+
35+
```clike
36+
set {file} to a new file at "test.txt"
37+
set {file} to the file at "test.txt"
38+
assert {file} is a file
39+
```
40+
41+
### File Properties
42+
43+
| Property | Description |
44+
| ---------- | --------------------------- |
45+
| `reader` | The file's input stream. |
46+
| `writer` | The file's output stream. |
47+
| `contents` | The file's string contents. |
48+
| `name` | The file name. |
49+
| `path` | The file path. |
50+
51+
```clike
52+
set {file} to a new file at "test.txt"
53+
assert name of {file} is "test.txt"
54+
set the contents of {file} to "hello there"
55+
assert the contents of {file} is "hello there"
56+
```
57+
58+
### Stream Properties
59+
60+
| Property | Description |
61+
| -------- | ----------------------------------- |
62+
| `all` | The input stream's entire contents. |
63+
| `line` | The input stream's next line. |
64+
65+
```clike
66+
set {file} to a new file at "test.txt"
67+
set {writer} to writer of {file}
68+
write "general kenobi" to {writer}
69+
close {writer} // make sure to close streams when finished
70+
set {reader} to reader of {file}
71+
set {line} to line of {reader}
72+
assert {line} is "general kenobi"
73+
close {reader} // make sure to close streams when finished
74+
```

0 commit comments

Comments
 (0)