diff --git a/package.json b/package.json index e9293674..889fb21b 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,10 @@ "default": "./dist/src/scripting/commands/index.js", "types": "./dist/src/scripting/commands/index.d.ts" }, + "./scripting/hooks": { + "default": "./dist/src/scripting/hooks/index.js", + "types": "./dist/src/scripting/hooks/index.d.ts" + }, "./scripting/interfaces": { "default": "./dist/src/scripting/interfaces/index.js", "types": "./dist/src/scripting/interfaces/index.d.ts" diff --git a/src/scripting/hooks/index.ts b/src/scripting/hooks/index.ts new file mode 100644 index 00000000..c266bed0 --- /dev/null +++ b/src/scripting/hooks/index.ts @@ -0,0 +1 @@ +export { useDelay } from '@scripting/hooks/useDelay.js' diff --git a/src/scripting/hooks/useDelay.ts b/src/scripting/hooks/useDelay.ts new file mode 100644 index 00000000..234c4163 --- /dev/null +++ b/src/scripting/hooks/useDelay.ts @@ -0,0 +1,11 @@ +let delayIdx = 0 + +export const useDelay = () => { + let delayOffset = 0 + + return (delayInMs: number = 0) => { + delayOffset += Math.floor(delayInMs) + + return `TIMERdelay${++delayIdx} -m 1 ${delayOffset}` + } +}