-
Notifications
You must be signed in to change notification settings - Fork 0
SpecialHandlerJS
YukkuriC edited this page Sep 4, 2026
·
2 revisions
taking an arbitrary pattern and retrieving its meanings
- registers a JS
tryMatch(pattern, env)factory consulted for every drawn pattern:- null / undefined: no match, falls through to later matches
- a
SpecialHandler: as a match result, executed afterwards
-
SpecialHandlerJS.create(action, name)to help build aSpecialHandler, in whichactioncould be another specially createdActionJS - chain setter
setTryMatchfor KJS-ish usage
// with or without `JS` both are fine
let { ActionJS, SpecialHandler } = HexJS
let testSeqFetcher = new SpecialHandler('yc:test_special_0', (pat, env) => {
let sig = pat.anglesSignature()
// env.castingEntity.tell(`try match: ${sig}`)
if (!sig.startsWith('deaqqdeaqq')) return // undefined & null: no match
return SpecialHandler.create(
new ActionJS((env, image, cont) => {
let player = env.castingEntity
player.tell(`matched: ${pat}, do further stuff here`)
}),
'test',
)
})this example takes inner data from inside the mod, and try to match the given pattern again, to hit those created too late to catch up with official action registry
NOTE: mod still under development, and inner structure might change
// runs after all normal & great pattern actions consumed
let fallbackMatcher = new SpecialHandler('hexjsneo:fallback', (pat, env) => {
let { MAP_NORMAL, MAP_GREAT } = HexJS.ActionRegistry.Companion
let sig = pat.anglesSignature()
if (MAP_NORMAL.containsKey(sig)) {
let reg = MAP_NORMAL.get(sig)
return SpecialHandler.create(reg.action, String(reg.id))
}
// TODO great pattern hot match
})