Handler Loop
The following methods, presented below, handle the repetition of a specified code at defined intervals without interruption.
Parameters
| Parameter | Description |
|---|---|
| every | Interval in milliseconds for code execution (default 60000) |
| code | The command code to be executed in the loop |
Example
Available Features
Within loop commands, the following functions are available:
$break- halt the loop command.$continue- skip the current iteration.$index- returns the number of times the loop has been executed so far.
- JavaScript
- Loader
<AoiClient>.loopCommand({
every: 5000,
code: `
$if[$index==5]
$break
$else
$print[Current index: $index]
$endif
`
})
<AoiClient>.loopCommand({
every: 5000,
code: `
$if[$index==5]
$continue
$else
$print[Current index: $index]
$endif
`
})
- ESModule
- Commonjs
export default {
every: 5000,
type: "loop",
code: `
$print[Count: $index]
`
};
module.exports = {
every: 5000,
type: "loop",
code: `
$print[Count: $index]
`
};