<spanclass=navbar-toggler-icon></span></button><divclass="collapse navbar-collapse"id=navbarSupportedContent><ulclass="navbar-nav me-auto mb-2 mb-lg-0"><liclass=nav-item><ahref=/Hilbish/class=nav-link>Home</a></li><liclass=nav-item><ahref=/Hilbish/install/class=nav-link>Install</a></li><liclass=nav-item><ahref=/Hilbish/docs/class=nav-link>Docs</a></li></ul></div></div></nav></header><divclass="container py-3 row"><divclass=containerstyle=width:240px><divclass="p-3 col"><ulclass="nav nav-pills mb-auto-collapse"id=navbarSupportedContent><liclass=nav-item><ahref=/Hilbish/docs/class=nav-link><strong>Introduction</strong></a></li><liclass=nav-item><ahref=/Hilbish/docs/getting-started/class=nav-link><strong>Getting Started</strong></a></li><liclass=nav-item><ahref=/Hilbish/docs/faq/class=nav-link><strong>Frequently Asked Questions</strong></a></li><liclass=nav-item><ahref=/Hilbish/docs/features/class=nav-link><strong>Features</strong></a></li><ulstyle=list-style:none><liclass=nav-item><ahref=/Hilbish/docs/features/runner-mode/class=nav-link>Runner Mode</a></li></ul><liclass=nav-item><ahref=/Hilbish/docs/api/class=nav-link><strong>API</strong></a></li><ulstyle=list-style:none><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.aliases/class=nav-link>Interface hilbish.aliases</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.completions/class=nav-link>Interface hilbish.completions</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.editor/class=nav-link>Interface hilbish.editor</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.history/class=nav-link>Interface hilbish.history</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.jobs/class=nav-link>Interface hilbish.jobs</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.os/class=nav-link>Interface hilbish.os</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.runner/class=nav-link>Interface hilbish.runner</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.timers/class=nav-link>Interface hilbish.timers</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/hilbish.userdir/class=nav-link>Interface hilbish.userDir</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/bait/class=nav-link>Module bait</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/commander/class=nav-link>Module commander</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/fs/class=nav-link>Module fs</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/hilbish/class=nav-link>Module hilbish</a></li><liclass=nav-item><ahref=/Hilbish/docs/api/terminal/class=nav-link>Module terminal</a></li></ul></ul></div></div><divclass="p-3 col"><div><h1>Interface hilbish.timers</h1><p><em>timeout and interval API<br></em></p><h3id=introduction>Introduction</h3><p>If you ever want to run a piece of code on a timed interval, or want to wait
a few seconds, you don’t have to rely on timing tricks, as Hilbish has a
timer API to set intervals and timeouts.</p><p>These are the simple functions <code>hilbish.interval</code> and <code>hilbish.timeout</code> (doc
accessible with <code>doc hilbish</code>). But if you want slightly more control over
them, there is the <code>hilbish.timers</code> interface. It allows you to get
a timer via ID and control them.</p><p>All functions documented with the <code>Timer</code> type refer to a Timer object.</p><p>An example of usage:</p><pretabindex=0><code>local t = hilbish.timers.create(1, 5000, function()
print 'hello!'
end)
t:stop()
print(t.running, t.duration, t.type)
t:start()
</code></pre><h3id=interface-fields>Interface fields</h3><ul><li><code>INTERVAL</code>: Constant for an interval timer type</li><li><code>TIMEOUT</code>: Constant for a timeout timer type</li></ul><h3id=object-properties>Object properties</h3><ul><li><code>type</code>: What type of timer it is</li><li><code>running</code>: If the timer is running</li><li><code>duration</code>: The duration in milliseconds that the timer will run</li></ul><h3id=functions>Functions</h3><h4id=start>start()</h4><p>Starts a timer.</p><h4id=stop>stop()</h4><p>Stops a timer.</p><h4id=createtype-time-callback>create(type, time, callback)</h4><p>Creates a timer that runs based on the specified <code>time</code> in milliseconds.