Timer
Auto-generated from
src/stdlib/timer.mcrs— do not edit manually.
API
- Timer.new
- Timer.start
- Timer.pause
- Timer.reset
- Timer.done
- Timer.elapsed
- Timer.remaining
- Timer.tick
- tick_to_seconds
- tick_to_ms
- seconds_to_ticks
- format_time_s
- format_time_m
- format_time_h
Timer.new
Create a new timer with the given duration in ticks.
fn new(duration: int) -> TimerTimer.start
Start or resume the timer.
fn start(self)Timer.pause
Pause the timer.
fn pause(self)Timer.reset
Reset elapsed ticks back to zero.
fn reset(self)Timer.done
Check whether the timer has reached its duration.
fn done(self) -> boolTimer.elapsed
Get elapsed ticks.
fn elapsed(self) -> intTimer.remaining
Get remaining ticks, clamped at zero.
fn remaining(self) -> intTimer.tick
Manually advance the timer by one tick when active.
fn tick(self)tick_to_seconds v1.0.0
Convert Minecraft ticks to whole seconds (20 ticks = 1 second).
fn tick_to_seconds(ticks: int): intParameters
| Parameter | Description |
|---|---|
ticks | Elapsed ticks |
Returns: ticks / 20
Example
let s = tick_to_seconds(100) // result: 5tick_to_ms v1.0.0
Convert Minecraft ticks to milliseconds (1 tick = 50 ms).
fn tick_to_ms(ticks: int): intParameters
| Parameter | Description |
|---|---|
ticks | Elapsed ticks |
Returns: ticks * 50
Example
let ms = tick_to_ms(20) // result: 1000seconds_to_ticks v1.0.0
Convert seconds to Minecraft ticks (1 second = 20 ticks).
fn seconds_to_ticks(s: int): intParameters
| Parameter | Description |
|---|---|
s | Seconds |
Returns: s * 20
Example
let t = seconds_to_ticks(5) // result: 100format_time_s v1.0.0
Extract seconds component from a tick count (0-59).
fn format_time_s(ticks: int): intParameters
| Parameter | Description |
|---|---|
ticks | Elapsed ticks |
Returns: (ticks / 20) % 60
Example
let s = format_time_s(1500) // result: 15 (75 seconds mod 60)format_time_m v1.0.0
Extract minutes component from a tick count (0-59).
fn format_time_m(ticks: int): intParameters
| Parameter | Description |
|---|---|
ticks | Elapsed ticks |
Returns: (ticks / 1200) % 60
Example
let m = format_time_m(72000) // result: 0 (1 hour)format_time_h v1.0.0
Extract hours component from a tick count.
fn format_time_h(ticks: int): intParameters
| Parameter | Description |
|---|---|
ticks | Elapsed ticks |
Returns: ticks / 72000
Example
let h = format_time_h(144000) // result: 2