-
Notifications
You must be signed in to change notification settings - Fork 0
ActionRegistryJS
YukkuriC edited this page Sep 4, 2026
·
2 revisions
registering certain patterns with actions
- = Registry ID + Pattern prototype + inner
ActionJS+ Great-pattern marker (default false) - weak-typed constructor
ActionRegistryJS.of(...): args in any order among pattern / id (string orResourceLocation) / action / isGreat, missing ones auto-filled (id from pattern signature, freshActionJS,false); only the pattern is required - transparent proxy of inner
ActionJS: operate setters (setOperate& variants),mediaCostandpreCheckMediaare callable directly on the registry object - great spells are auto-tagged with per-world / enlightenment tags
let { ActionJS, ActionRegistryJS } = HexJS
let { HexPattern } = HexJS.APIFlat
// the way of least sugar
let action = new ActionJS()
/* omitted code preparing it */
let pattern = HexPattern.fromAnglesUnchecked('deaqqwww', 'south_east')
let registrySugar0 = new ActionRegistryJS(pattern, 'some_namespace:some_id', action, false) // last bool for "isGreat"
// the way of more sugar
// inner action created automatically, and its methods piped out
let registrySugar1 = ActionRegistryJS.of(
// we don't care orders anymore
'some_namespace:some_id',
pattern,
true,
)
.setOperateMutableStack((stack, env) => {
registrySugar1.preCheckMedia(env, 114514)
})
.setOperateInParens((env, image, cont, thisIota) => {
// and these methods pipe between themselves, too
})