
skLambda
Skript addon that adds lambda functions and listeners to Skript.
!Cover
A Skript addon that lets you treat behavior as a value, and cut a lot of boilerplate while you're at it. It adds:
- Lambdas: Small functions you save in a variable, pass around, and run later. They support closures, default parameters, and piping.
- Predicates: Reusable yes/no tests you can combine with all, any, or none, or count how many pass.
- List operations: Map, reduce, scan, zip, sort, highest/lowest, and paging, without writing the loops yourself.
- Self-cleaning listeners: Temporary event listeners scoped to one player or command, with a timer, a hit count, and lifecycle callbacks. They stop themselves.
- Async: Run a lambda off the main thread with futures,
wait foran event or result without freezing the server, andwatcha value or condition.
Links
Example: same task, two ways
The task: tell the player to mine 10 stone in 30 seconds. Give a diamond if they finish, say "too slow" if they don't.
Without skLambda
on break of stone:
if {challenge::%player%} is not set:
stop
add 1 to {challenge::progress::%player%}
if {challenge::progress::%player%} >= 10:
send "you did it!" to player
give 1 diamond to player
delete {challenge::%player%}
delete {challenge::progress::%player%}
command /challenge:
trigger:
set {challenge::%player%} to true
set {challenge::progress::%player%} to 0
send "mine 10 stone in 30s" to player
wait 30 seconds
if {challenge::%player%} is set:
send "too slow" to player
delete {challenge::%player%}
delete {challenge::progress::%player%}
Lots to do by hand: a global on break of stone that runs for every player, a flag variable, a counter variable, a separate wait for the timeout, and delete lines everywhere to clean up.
With skLambda
command /challenge:
trigger:
send "mine 10 stone in 30s" to player
listen for block break where event-block is stone:
countdown: 30 seconds
triggers: 10
every 1 second:
send action bar "%remaining triggers% left — %remaining countdown%" to event-player
on completion:
send "you did it!" to event-player
give 1 diamond to event-player
on timeout:
send "too slow!" to event-player
That's it. The listener belongs to this one command run. The counter, the timer, and the live action-bar readout are built in, and when it finishes or times out, it cleans up by itself.
More than listeners
Save a test and run it over a list. Predicates pair with Skript's own filter, and list operations skip the loop:
# keep only the players who are AFK
set {_afk} to lambda (p: player): {_p}'s idle time > 5 minutes
set {_idle::*} to all players where [{_afk} passes for input]
# score every player with a lambda, grab the winner
set {_score} to lambda (p: player) -> number:
return {_p}'s level
set {_mvp} to highest of all players by {_score}
New in 1.3.0, you can pause a trigger and wait without freezing the server:
command /confirm:
trigger:
send "type 'yes' in chat within 15s to confirm." to player
wait for next chat where player is sender within 15 seconds:
if message is "yes":
send "confirmed!" to player
on timeout:
send "cancelled — no reply." to player
The trigger picks up right where it left off when the player chats, and the server keeps ticking the whole time. You can also wait for a background job (future of calling lambda ...) or watch a value or condition and react only when it changes.
Full guides and dozens of runnable examples are on the wiki.
Requirements
- Paper 1.21.1+
- Skript 2.15+
License
MIT
Stats
skLambda uses bStats for anonymous usage stats. You can opt out in plugins/bStats/config.yml.
NOTES
if you experience any problems, let me know on discord eult, discord server
