
skLambda
Skript addon that adds lambda functions and listeners to Skript.
Оцените первым
158
3
Список изменений
skLambda 1.5.0
Supports: Paper 1.21.1+ · Skript 2.15+ Want the full details? wiki: New-Features
Bug fixes and playing nicer with other addons. Most of it came from running skLambda next to Skript core, SkBee, skript-reflect and skript-gui and finding the places where they quietly fought over the same wording.
New effects
- Format a GUI slot with a lambda:
format gui slot[s] %objects% of %gui% with %itemtype% [handled by %lambda%]puts an item in a skript-gui slot and hands the click to a lambda, so a shared "close" or "back" button is written once and reused instead of getting its own inline section in every menu. The handler gets the player, the slot index and the clicked item, and a shorter lambda just ignores what it does not declare. Addstealable(orremovable) before the item to let players take it.unformat gui slot[s] %objects% of %gui%clears them again. - Fill a GUI from a list:
fill gui %gui% from %objects% rendered with %lambda% [handled by %lambda%] [starting at slot %number%]is a data-driven menu in one line. The renderer turns each element into an item, the handler gets the element, the player and the slot. Each slot closes over its own element, so one handler covers the whole menu. Pair it withpage %number% of %objects% by %number%and a long list pages itself. - Both only register when skript-gui is installed, and skLambda does not build against it, so nothing changes if you do not use it. skript-gui is now a soft dependency, so it always loads first. Before that, plugin load order decided whether the effects existed at all.
New listener options
- Inventory owners:
owner:now takes an inventory as well as an offline player, entity, chunk or world. The listener or watcher stops itself when the last viewer closes that menu, which is what you want for a watcher driving a live GUI. Before, awatch (balance of player) every 1 secondfeeding an open menu kept polling after the player closed it. Two inventories count as the same owner only when they are the same object, so two empty chests of the same size do not get mixed up.
New conditions
- Unambiguous future state:
future [of] %future% is (done|completed|resolved),is pendingandhas failed, each with a negated form. SkBee defines%advancementprogress% is doneand claims that wording first, so a plainif {_f} is done:was silently becoming an advancement check. Writeif future {_f} is done:and it always reaches skLambda.is resolvedandis completedwere never in conflict and stay the shortest safe way to ask.
New expressions
- Every value a lambda returned:
results of calling lambda %object% [with %objects%]is the plural spelling ofresult of calling lambdaand hands back the whole list when the body returned one. The singular still gives the first value, so nothing you wrote changes.
Improvements
- skript-reflect sections and function references work as lambdas: anywhere skLambda takes a lambda, it now also takes a section stored with
create new section stored in {_s}and a function reference fromthe function "name". So{_list::*} mapped with {_section},sorted by {_section},pipe 5 through {_section},{_list::*} where [{_section} passes for input]andfuture of calling lambda {_section}all run code you already wrote. A section takes its arguments throughwith arguments variables, and itsreturnis what comes back. A function reference written with arguments, likethe function "add" called with 100, keeps them bound as the leading ones, exactly likewith ... bound. skLambda does not build against skript-reflect, so none of this loads when it is absent. - Lambdas are Java functional interfaces: a lambda is now a
Consumer,BiConsumer,Function,Predicate,Supplier,RunnableandComparator, so you can hand one straight to any Java method that wants one. Through skript-reflect that means{_stack}.editMeta({_lambda}),{_list}.removeIf({_lambda}),{_list}.sort({_lambda})and{_optional}.map({_lambda})work directly, without an adapter call or a reflect section. Whatever calls it decides which shape applies, so the same lambda can be a consumer in one place and a predicate in the next.asPredicate(),asFunction(),asBiFunction(),asConsumer()andasSupplier()are real methods on the lambda now too, the way the wiki always described them. callandinvokework as statements:call lambda {_x}andinvoke lambda {_x}parse on their own line, not just as expressions.run lambda {_x}is unchanged.- Lambdas can return a list:
return {_list::*}used to fail with a confusing error borrowed from another addon and then hand back nothing. It works now, readable throughresults of calling lambda.function lambda "name"keeps a function's whole result too, instead of dropping everything after the first value. - Type names read properly: Skript's warnings said "a types.lambda cannot be saved" because skLambda shipped a language file with its type names commented out. It says "a lambda" now. Same for listeners, futures and end reasons.
Bug fixes
mapped with [...]no longer crashes:set {_widths::*} to ({_headers::*} mapped with [length of "%input%"])threwUnparsedLiterals must be converted before useat runtime, because skLambda's%objects% mapped with %object%claimed the line ahead of Skript core's bracket version and then choked on the bracket. Every lambda slot now declines raw unparsed text, so core'smapped with,transformed using,reduced withandwherebracket forms all reach Skript. Fixed in all fourteen places a lambda is taken.result of calling lambdagave nothing: skLambda's ownresult[s] of %futures%outranked it, and since a future slot accepts any object through a converter, it swallowed the whole line. Both sides now check what they are actually handed.- Parameter defaults broke on brackets, commas and quotes:
lambda (a: number = (1 + 2)),lambda (a: number = max(1, 9)),lambda (a: string = "x, y")andlambda (a: string = "a)b")all failed, with the error claiming "Lambda definitions need a body" when the body was right there. The signature parser now scans brackets and quoted text properly. sorted byleft lists untouched: one element whose key lambda returned nothing was enough to leave the entire list unsorted, and a text key never ordered anything at all. Nothing-keys now sink to the end in their original order, keys of different kinds group by kind, anything comparable sorts properly, and equal keys keep their original order.- A skipped argument leaked the surrounding variable: calling a lambda without an argument for a parameter that shares a name with a captured local showed the capture instead of nothing, the opposite of the documented rule that parameters shadow captures. A call missing a required argument is refused outright now, so an arity mismatch like
(1, 2) mapped with %2-arg lambda%gives you nothing instead of a plausible-looking wrong number. - A fold step returning nothing corrupted the rest: in
reduced withandscanned with, a lambda that returned nothing handed the next step an empty accumulator, so the running total reset partway through. Such a step is skipped now and the fold carries on. containsnever found a listener:if all active listeners contains {_l}:was always false, and so was comparing two listeners withis, because Skript had no comparator for the type. Listeners, futures and lambdas now compare by identity, socontains,isandis notwork on all three.new valueandold valuewere claimed in every script: those words, pluscurrent value,previous value,former valueandchanged value, were taken by skLambda anywhere on the server and quietly read as nothing outside a watcher, whileend reasonhad guarded itself properly all along. They error at parse time now, telling you where they belong. This one can break a script that already loads: if you used any of those exact words for something else, the line is rejected instead of silently giving you nothing. Rename it, or read the value you meant directly.script of %listener%disagreed withscript: it returned a bare file name while Skript'sscriptincludes the folder, so comparing the two never matched. It now spells the script the same way Skript does.
Full Changelog: https://github.com/ahmadmsaleem/skLambda/compare/1.4.0...1.5.0
Файлы
skLambda-1.5.0.jar(267.86 KiB)
ОсновнойМетаданные
Канал релиза
Release
Номер версии
1.5.0
Загрузчики
PaperPurpur
Версии игры
1.21–26.2
Загрузок
5
Дата публикации
25.08.2026
