Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0ef9b00
Update pdc.sk
devdinc Jan 30, 2026
e0162cb
Update pdc.sk
devdinc Jan 30, 2026
b09252c
Update test-skripts.yml
devdinc Jan 30, 2026
1158a5e
test: implement before/after hooks and add Skript test tracker support
devdinc Jan 30, 2026
ad133c1
Create singlelinemulticonditional.sk
devdinc Jan 30, 2026
2fa7777
Create scopedvariable.sk
devdinc Jan 30, 2026
d077c65
Create scopedvariable.sk
devdinc Jan 30, 2026
af3b8b2
Create repeateffect.sk
devdinc Jan 30, 2026
83707bd
Update README.md
devdinc Jan 30, 2026
029953f
Update testframework.md
devdinc Jan 30, 2026
72b64b6
Update testframework.md
devdinc Jan 30, 2026
ff46235
Refactor for best load order, scoped variable fixes, pdc coercing bas…
devdinc Jan 31, 2026
3d9d60d
fix variable resolution inside scoped variables
devdinc Jan 31, 2026
2f545b8
fix repeat effect, alpha improvements on scoped variables, test frame…
devdinc Feb 1, 2026
ce64de0
eventspecifiedvariables.sk
devdinc Feb 1, 2026
cd2701a
event specified variables finish?
devdinc Feb 1, 2026
9b70f47
event specified variables new string expression, scoped variable fixes
devdinc Feb 2, 2026
bd350b1
pdc fix, scoped variable changes
devdinc Feb 2, 2026
15e14e4
fix pdc pdt
devdinc Feb 2, 2026
bbb4e4a
some pdc tests
devdinc Feb 2, 2026
408ded4
fix pdc pdt
devdinc Feb 2, 2026
3649ada
fix all pdc unspecified pdt
devdinc Feb 3, 2026
95caef3
test: breaking changes; tests are now associated with scripts, event-…
devdinc Feb 4, 2026
2b7d209
Update test-skripts.yml
devdinc Feb 4, 2026
d066465
pdc: breaking changes; namespaced key expression is removed, fixes wh…
devdinc Feb 4, 2026
ac9709b
test: fix error counting
devdinc Feb 4, 2026
7f294fb
test: there is a chanche there is a bug, try to fix, skript native te…
devdinc Feb 4, 2026
254d97b
typo
devdinc Feb 4, 2026
e012072
test: skript native test force run
devdinc Feb 4, 2026
d0b01ef
test: skript native test force run, another try
devdinc Feb 4, 2026
98cb948
update debug
devdinc Feb 4, 2026
8046788
remove wait to see if it works
devdinc Feb 4, 2026
400aa5a
adjust test framework and test-skripts workflow to make sure native l…
devdinc Feb 4, 2026
f85d903
multiline lambda
devdinc Feb 5, 2026
d5fbd03
remove empty file
devdinc Feb 5, 2026
e344590
restructure tests
devdinc Feb 5, 2026
9525e94
update documentation
devdinc Feb 5, 2026
2a89497
restructure tests for load order
devdinc Feb 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions .github/workflows/test-skripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: |
mkdir -p build/libs
curl -L -o build/libs/skript-reflect.jar \
https://github.com/SkriptLang/skript-reflect/releases/download/v2.6.1/skript-reflect-2.6.1.jar
https://github.com/SkriptLang/skript-reflect/releases/download/v2.6.3/skript-reflect-2.6.3.jar

- name: Download Routines from JitPack
run: |
Expand All @@ -54,26 +54,41 @@ jobs:

curl -L --fail -o build/libs/skript-reflect/routines-paper.jar \
https://jitpack.io/com/github/devdinc/routines/routines-paper/v2.2.1/routines-paper-v2.2.1.jar
# Disable pdc for now, i want to remove skbee req
# Disable config reload

- name: Prepare scripts
run: |
mkdir -p tests/scripts
rsync -av scripts/ tests/scripts/
mv tests/scripts/libs/singlelinesection.sk tests/scripts/libs/0_singlelinesection.sk
rm -f tests/scripts/utils/testframework.sk
rm -f tests/scripts/utils/configreloadv2.sk

- name: Force-load Skript native test suite
run: |
cat > tests/zzzz_force_native_tests.sk <<'EOF'
import:
ch.njol.skript.test.runner.SkriptTestEvent

test "run devdinc tests":
event is instance of SkriptTestEvent
send "Running devdinc tests" to console

set {_list::string} to "f39f0f4a-31ee-4b71-87e9-38ddba3a2313"
set {_list::boolean} to false

call custom event "skriptTest" with {_list::*}

set {_tests::*} to all tests
autorun {_tests::*}
EOF

- name: Run tests
uses: devdinc/skript-test-action@v1.3
with:
skript_repo_url: https://github.com/devdinc/Skript.git
skript_repo_url: https://github.com/SkriptLang/Skript.git
# directory where your test scripts are located (relative to repo root)
test_script_directory: tests

# Skript version or ref (tag, branch, or commit)
skript_repo_ref: ef28bd5 # 2.13.2
skript_repo_ref: dev/feature

# directory containing addon/plugin jars (relative to repo root)
extra_plugins_directory: build/libs
Expand Down
2 changes: 1 addition & 1 deletion .restructure
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using scripts

prefix:
0 libs/singlelinesection.sk
0 libs/parser/singlelinesection.sk
1 libs/functionsv2.sk
2 libs/routines.sk
3 .
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,3 @@ If you encounter errors such as `Can't understand this expression`, the issue is

Skript loads files alphabetically, with folders being prioritized. To control load order, prefix the Skript file with a folder or a character such as `0_` or `!`
(e.g., `!testframework.sk`)

## TODO

Currents plans include:
- multiline lambda expression
- making the test framework support extending over the skriptlang native test suit
- Auto casting for primitives, pdc.sk(new Byte,Integer etc)
97 changes: 81 additions & 16 deletions docs/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ All generated lambdas are real Java proxy instances.

---

## Core Lambda Syntax
## Core Lambda Syntax (Single-Line)

### 1. Returning Lambda

```skript
lambda [<variables>]: <expression>
```
````

* Returns a value
* Automatically mapped to a Java functional interface
* Return vs effect behavior is auto-detected

---

Expand All @@ -66,6 +67,67 @@ lambda [<variables>]:+ <expression>

---

## Multiline Lambdas (Section-Based)

Lambdas may also be written as **multiline sections**.
These allow more complex logic while still compiling into Java functional interfaces.

Multiline lambdas are created using **typed aliases** (`new runnable:`, `new function {_x}:`, etc.).

---

### Multiline Non-Returning Lambda

Maps to:

* `Runnable`
* `Consumer<T>`
* `BiConsumer<T, U>`

depending on arity.

```skript
set {_task} to new runnable:
broadcast "working"
broadcast "still working"
```

Rules:

* Produces **no return value**
* All lines must be **effects**
* `return` is not allowed

---

### Multiline Returning Lambda

Multiline returning lambdas **must use the `return` effect**.
The lambda does **not** infer a return value from the last line.

```skript
set {_double} to new function {_x}:
broadcast "doubling %{_x}%"
return {_x} * 2
```

Rules:

* `return <expression>` is **mandatory**
* The final line does **not** need to be an expression
* Effects may appear anywhere before `return`
* Multiple control-flow paths may use `return`

Maps to:

* `Supplier<T>`
* `Function<T, R>`
* `BiFunction<T, U, R>`

based on arity.

---

## Java Interface Mapping (Arity-Based)

The target Java interface is selected based on **parameter count** and **return behavior**.
Expand Down Expand Up @@ -93,7 +155,9 @@ The target Java interface is selected based on **parameter count** and **return

> Lambdas with more than **2 parameters are not supported**.

### Workaround for Higher Arity
---

## Workaround for Higher Arity

Pass a single composite object instead:

Expand Down Expand Up @@ -196,7 +260,8 @@ biaccepter {_a}, {_b}:

```skript
set {_f} to function {_x}: {_x} * 2
set {_r} to runnable: broadcast "hello"
set {_r} to runnable:
broadcast "hello"
```

---
Expand Down Expand Up @@ -239,38 +304,38 @@ set {_adder} to lambda {_m}:- {_m}.values().stream().forEach({_inlineforeach})

## Limitations

* Lambdas are **strictly single-line**
* Returning lambdas (`:` / `:+`) **cannot contain effects**
* Non-returning lambdas (`:-`) **cannot contain expressions**
* Non-returning lambdas **cannot return values**
* Lambdas may be **single-line or multiline**
* Single-line lambdas infer return vs effect behavior
* Multiline returning lambdas **require `return`**
* Multiline non-returning lambdas **must not return**
* Lambdas are limited to **0–2 parameters**
* Variable lists as parameters are **not supported**
* Arrays are unreliable inside lambdas:

* Indexing (`[n]`) does not work
* Use `spread(...)` before passing arrays
* Imported classes or complex expressions **may fail inline**

* Mitigations:
* Imported classes or complex expressions may fail inline

* Explicitly use `:+` or `:-`
* Wrap logic in a normal function and call it
* Prefer multiline lambdas
* Or wrap logic in a normal Skript function

---

## Notes

* Return vs effect behavior is **auto-detected** unless overridden with `:-` or `:+`
* Single-line lambdas auto-detect return vs effect
* Multiline lambdas require explicit intent
* Lambdas are real Java proxy objects and fully compatible with:

* Java streams
* Java APIs
* skript-reflect usage
* Experimentally, local values are passed into lambda sections. Use with care.

---

* Experimentally local values are passed into the section. You can use local values, but be careful.

## Planned

* Additional utility expressions (e.g., `for each` helpers)
* These will be introduced in **separate files**

Loading