Something went wrong. Try again.
Scripts for playing Adventure Land
Something went wrong. Try again.
801 B · 21 lines
TypeScript
at main
12345678910111213141516171819202122/** * How often a script re-evaluates what to do next. This is unrelated to any * server tick rate — Adventure Land doesn't expose one to scripts. Actions * are independently rate-limited by their own cooldowns (attack speed, skill * cooldowns, etc.), which the guard functions like `can_attack()` and * `can_use()` already check. This just needs to be frequent enough to react * promptly once those cooldowns clear. */export const DEFAULT_LOOP_INTERVAL_MS = 1000 / 4;
/** * Runs `tick` on a fixed interval, defaulting to * {@link DEFAULT_LOOP_INTERVAL_MS}. Returns a function that stops it. */export function startLoop( tick: () => void, intervalMs: number = DEFAULT_LOOP_INTERVAL_MS,): () => void { const id = setInterval(tick, intervalMs); return () => clearInterval(id);}