# API

## Timer

| Primary Variables |                                                                             |
| ----------------- | --------------------------------------------------------------------------- |
| timerState        | Controls if the timer is *Counting* or *Disabled.*                          |
| timerType         | Controls if the timer will count-up, count-down, or count-up infinitely.    |
| startTime         | Time the timer will start from.                                             |
| finishTime        | Time the timer will stop at.                                                |
| timerSpeed        | Rate at which the timer adds or subtracts time.                             |
| loop              | Timer will auto restart when complete.                                      |
| useSystemTime     | Timer will run as a clock and output system time.                           |
| timesUpEvent      | A UnityEvent that can trigger custom scripting functions when time is up.   |
| setZeroTimescale  | Sets Time.timescale to 0 when time is up.                                   |
| textType          | Assign a default Unity UI Text or Text Mesh Pro UGUI component.             |
| timerTextDefault  | Assign a UI Text component to output a formatted string.                    |
| timerTextTMPUGUI  | Assign a Text Mesh Pro UGUI component to output a formatted string.         |
| displayOptions    | Toggle specific time value fields in the output string.                     |
| leadingZero       | Toggle the leading zero on specific time value fields in the output string. |

| Time Events | Create a list of custom events, the timer will trigger when the assigned time is reached. |
| ----------- | ----------------------------------------------------------------------------------------- |
| eventName   | The name of the custom time event.                                                        |
| eventTime   | The time the event will be triggered.                                                     |
| timeEvent   | The event that's invoked when the event time is reached.                                  |

| Methods               |                                                                                           |
| --------------------- | ----------------------------------------------------------------------------------------- |
| AddTime(double)       | Adds the value to the timer value, use a negative value to subtract time.                 |
| ClampGameTime         | Clamps the timer value to ensure it does not exceed the max double value of 922337193600. |
| GetTimerValue         | Returns the timer value as a double.                                                      |
| SetTimerValue(double) | Set timer to the value.                                                                   |
| StartTimer            | Sets the timer state to counting.                                                         |
| StopTimer             | Sets the timer state to disabled.                                                         |
| UpdateUIText          | Updates the assigned text component to display the current formatted time string.         |
| ResetTimer            | Sets the timer value to start time.                                                       |
| RestartTimer          | Sets the timer value to start time, and starts the timer if it's not running.             |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://timersandclocks.turnthegameon.com/api/timer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
