0.0.12 • Published 3 years ago
@trim21/cactbot-types v0.0.12
Cactbot type definition generate from source
you can install @trim21/cactbot-types
with npm, so you don't need cactbot source anymore.
./resources
, ./ui/
and ./types/
are generated with tsc
from cactbot source.
there are also some helper in user_trigger.mjs
, you can find usage in ./test/
dir.
This package is intent to be used with typescript, and your own webpack or esbuild packaging tool.
quick start
dsr.ts
:
import type {
Data as BaseData,
} from '@trim21/cactbot-types/ui/raidboss/data/06-ew/ultimate/dragonsongs_reprise_ultimate';
import { defineTrigger } from '@trim21/cactbot-types';
interface DSRData {
marked: boolean;
nameToJobID?: Record<string, number>,
p5Lightning: Array<{ name: string, jobID: number }>;
p5DeadCall: Array<{ name: string, jobID: number }>;
tower: Array<{
x: number;
y: number;
num: number;
}>;
}
export default defineTrigger<DSRData, BaseData>({
zoneId: ZoneId.DragonsongsRepriseUltimate,
initData() {
return {
marked: false,
tower: [],
p5Lightning: [],
p5DeadCall: [],
};
},
triggers: [
{
id: 'DSR ...',
type: 'StartsUsing',
netRegex: NetRegexes.startsUsing({...}),
preRun: (data, matches) => {},
alertText: (data) => {}
}
],
});
index.ts
import trigger from './dsr';
import _Conditions from '@trim21/cactbot-types/resources/conditions';
import _ContentType from '@trim21/cactbot-types/resources/content_type';
import _NetRegexes from '@trim21/cactbot-types/resources/netregexes';
import _Regexes from '@trim21/cactbot-types/resources/regexes';
import { Responses as _Responses } from '@trim21/cactbot-types/resources/responses';
import _Outputs from '@trim21/cactbot-types/resources/outputs';
import _Util from '@trim21/cactbot-types/resources/util';
import _ZoneId from '@trim21/cactbot-types/resources/zone_id';
import _ZoneInfo from '@trim21/cactbot-types/resources/zone_info';
import type { RaidbossData } from '@trim21/cactbot-types/types/data';
import type { TriggerSet } from '@trim21/cactbot-types/types/trigger';
import type { EventMap, EventType } from '@trim21/cactbot-types/types/event';
type IAddOverlayListener = <T extends EventType>(
event: T,
cb: EventMap[T]
) => void;
declare global {
const addOverlayListener: IAddOverlayListener;
const Options: {
PlayerNicks: Record<string, string>;
Triggers: {
push<T extends RaidbossData>(item: Omit<TriggerSet<T>, 'initData'> & { initData(): Partial<T> }): void
};
};
// Global variables
const Conditions: typeof _Conditions;
const ContentType: typeof _ContentType;
const NetRegexes: typeof _NetRegexes;
const Regexes: typeof _Regexes;
const Responses: typeof _Responses;
const Outputs: typeof _Outputs;
const Util: typeof _Util;
const ZoneId: typeof _ZoneId;
const ZoneInfo: typeof _ZoneInfo;
// options of modules
// const RaidbossOptions: typeof _RaidbossOptions;
}
Options.Triggers.push(trigger);