Skip to content

MishapJS

YukkuriC edited this page Sep 5, 2026 · 1 revision

highly customizable mishap types

  • declaring the type using MishapJS.type() first, quite similar to IotaJS
  • calling type.create() or type.create(data) for a mishap of this type
  • KJS-ish piped methods to override all behaviors of created mishaps

Examples

let {
    ActionRegistry,
    MishapJS,
    APIFlat: { HexPattern },
} = HexJS

// declaring a mishap type with custom message & execution logic, everything else default
let MishapSus = MishapJS.type()
    .setConstErrorMessage(Text.red('SUS'))
    .setExecute((mishap, env, ctx, stack) => {
        env.castingEntity.kill()
    })
this.MishapSus = MishapSus

// a familiar action throwing this new mishap
// pattern credit: HexTweaks
let actionSus = ActionRegistry.of(
    HexPattern.fromAnglesUnchecked('dewdeqwwedaqedwadweqewwd', 'west'),
    'yc:sus',
    true,
).setOperate(() => MishapSus.create())

Clone this wiki locally