Contra › class › Timer
From Botdom Documentation
Contra contains a Timer class. This allows module developers to create modules which used timed events. An example of a module that would use this is trivia.
Contents |
Location
~/core/Timer_class.php
Properties
protected $events = array(); // Array to store timed events. protected $timers = array(); // Array to store timers... protected $rands = array(); // This is used to help generate random keys. protected $Bot; // Instance of the Bot class.
Methods
__construct
Called when instantiated, just stores the reference to the Bot class.
Parameters: $Bot - object. A reference to the Bot class.
addEvt
Add a timer event!
Parameters: $module - string. The name of the module using the event. $time - integer. Number of seconds the timer should last. $data - mixed. Additional data to be passed to the module's event. $event - string. Event to trigger when the time is up. Defaults to "timer". $mute - bool(true/false). Whether to prevent the timer displaying a notice or not. Defaults to false(no).
When used, the method returns a unique ID code for the timer. Example:
$timer = $this->Time->addEvt($this->name, 10, false, false, false); // Trigger the timer event for this module after 10 seconds have passed!
delEvt
Delete a timer event!
Parameters: $EVENT_ID - string. ID code for the event to be deleted.
Returns true on success and false on failure. Example:
$this->Timer->delEvt($timer);
triggerEvents
Trigger any events waiting in queue.
Events
Returns an array containing the events and their details.
Parameters: $display - bool(true/false). Whether to output the array straight to the console or not. Defaults to true(yes).
Example:
$this->Timer->Events();
Start
Starts a timer, stop-watch style! The timer's ID code is returned. Example:
$stopwatch = $this->Timer->Start();
Stop
Stops a timer. Returns the number of seconds elapsed since the timer was started.
Parameters: $ID - string. ID Code for the timer.
Example:
$lap = $this->Timer->Stop($stopwatch);
Timers
The timer equivalent of $this->Events();

