Class TimerGauge

Animated countdown timer, extends Geyser.Gauge

Info:

  • Copyright: 2020 Damian Monogue
  • License: MIT, see LICENSE.lua
  • Author: Damian Monogue

Methods

timergauge:show2() Shows the TimerGauge.
timergauge:hide2() Hides the TimerGauge.
timergauge:start([show]) Starts the timergauge.
timergauge:stop([hide]) Stops the timergauge.
timergauge:pause([hide]) Alias for stop.
timergauge:reset() Resets the time on the timergauge to its original value.
timergauge:restart([show]) Resets and starts the timergauge.
timergauge:getTime(format) Get the amount of time remaining on the timer, in seconds
timergauge:finish([skipHook]) Sets the timer's remaining time to 0, stops it, and executes the hook if one exists.
timergauge:setTime(time) Sets the amount of time the timer will run for.
timergauge:setUpdateTime(updateTime) Changes the time between gauge updates.
timergauge:new(cons, parent) Creates a new TimerGauge instance.


Methods

timergauge:show2() line 40
Shows the TimerGauge. If the manageContainer property is true, then will add it back to its container
timergauge:hide2() line 49
Hides the TimerGauge. If manageContainer property is true, then it will remove it from its container and if the container is an HBox or VBox it will initiate size/position management
timergauge:start([show]) line 70
Starts the timergauge. Works whether the timer is stopped or not. Does not start a timer which is already at 0

Parameters:

  • show boolean override the autoShow property. True will always show, false will never show. (optional)

Usage:

    myTimerGauge:start() --starts the timer, will show or not based on autoShow property
    myTimerGauge:start(false) --starts the timer, will not change hidden status, regardless of autoShow property
    myTimerGauge:start(true) --starts the timer, will show it regardless of autoShow property
timergauge:stop([hide]) line 94
Stops the timergauge. Works whether the timer is started or not.

Parameters:

  • hide boolean override the autoHide property. True will always hide, false will never hide. (optional)

Usage:

    myTimerGauge:stop() --stops the timer, will hide or not based on autoHide property
    myTimerGauge:stop(false) --stops the timer, will not change hidden status, regardless of autoHide property
    myTimerGauge:stop(true) --stops the timer, will hide it regardless of autoHide property
timergauge:pause([hide]) line 111
Alias for stop.

Parameters:

  • hide boolean override the autoHide property. True will always hide, false will never hide. (optional)
timergauge:reset() line 116
Resets the time on the timergauge to its original value. Does not alter the running state of the timer
timergauge:restart([show]) line 127
Resets and starts the timergauge.

Parameters:

  • show boolean override the autoShow property. true will always show, false will never show (optional)

Usage:

    myTimerGauge:restart() --restarts the timer, will show or not based on autoShow property
    myTimerGauge:restart(false) --restarts the timer, will not change hidden status, regardless of autoShow property
    myTimerGauge:restart(true) --restarts the timer, will show it regardless of autoShow property
timergauge:getTime(format) line 197
Get the amount of time remaining on the timer, in seconds

Parameters:

  • format string Format string for how to return the time. If not provided defaults to self.timeFormat(which defaults to "S.t").
    If "" is passed will return "" as the time. See below table for formatting codes
    format code what it is replaced with
    S Time left in seconds, unbroken down. Does not include milliseconds.
    IE a timer with 2 minutes left it would replace S with 120
    dd Days, with 1 leading 0 (0, 01, 02-...)
    d Days, with no leading 0 (1,2,3-...)
    hh hours, with leading 0 (00-24)
    h hours, without leading 0 (0-24)
    MM minutes, with a leading 0 (00-59)
    M minutes, no leading 0 (0-59)
    ss seconds, with leading 0 (00-59)
    s seconds, no leading 0 (0-59)
    t tenths of a second
    timer with 12.345 seconds left, t would
    br replaced by 3.
    mm milliseconds with leadings 0s (000-999)
    m milliseconds with no leading 0s (0-999)

Usage:

    myTimerGauge:getTime() --returns the time using myTimerGauge.format
    myTimerGauge:getTime("hh:MM:ss") --returns the time as hours, minutes, and seconds, with leading 0s (01:23:04)
    myTimerGauge:getTime("S.mm") --returns the time as the total number of seconds, including milliseconds (114.004)
timergauge:finish([skipHook]) line 263
Sets the timer's remaining time to 0, stops it, and executes the hook if one exists.

Parameters:

  • skipHook boolean use true to have it set the timer to 0 and stop, but not execute the hook. (optional)

Usage:

    myTimerGauge:finish() --executes the hook if it has one
     myTimerGauge:finish(false) --will not execute the hook
timergauge:setTime(time) line 294
Sets the amount of time the timer will run for. Make sure to call :reset() or :restart() if you want to cause the timer to run for that amount of time. If you set it to a time lower than the time left on the timer currently, it will reset the current time, otherwise it is left alone

Parameters:

  • time number how long in seconds the timer should run for

Usage:

    myTimerGauge:setTime(50) -- sets myTimerGauge's max time to 50.
timergauge:setUpdateTime(updateTime) line 318
Changes the time between gauge updates.

Parameters:

  • updateTime number amount of time in milliseconds between gauge updates. Must be a positive number.
timergauge:new(cons, parent) line 474
Creates a new TimerGauge instance.

Parameters:

  • cons table a table of options (or constraints) for how the TimerGauge will behave. Valid options include:
    name description default
    time how long the timer should run for
    active whether the timer should run or not true
    showTime should we show the time remaining on the gauge? true
    prefix text you want shown before the time. ""
    suffix text you want shown after the time. ""
    timerCaption Alias for suffix. Deprecated and may be remove in the future
    updateTime number of milliseconds between gauge updates. 10
    autoHide should the timer :hide() itself when it runs out/you stop it? true
    autoShow should the timer :show() itself when you start it? true
    manageContainer should the timer remove itself from its container when you call
    :hide() and add itself back when you call :show()?
    false
    timeFormat how should the time be displayed/returned if you call :getTime()?
    See table below for more information
    "S.t"

    Table of time format options
    format code what it is replaced with
    S Time left in seconds, unbroken down. Does not include milliseconds.
    IE a timer with 2 minutes left it would replace S with 120
    dd Days, with 1 leading 0 (0, 01, 02-...)
    d Days, with no leading 0 (1,2,3-...)
    hh hours, with leading 0 (00-24)
    h hours, without leading 0 (0-24)
    MM minutes, with a leading 0 (00-59)
    M minutes, no leading 0 (0-59)
    ss seconds, with leading 0 (00-59)
    s seconds, no leading 0 (0-59)
    t tenths of a second
    timer with 12.345 seconds left, t would
    br replaced by 3.
    mm milliseconds with leadings 0s (000-999)
    m milliseconds with no leading 0s (0-999)

  • parent The Geyser parent for this TimerGauge

Usage:

    local TimerGauge = require("MDK.timergauge")
    myTimerGauge = TimerGauge:new({
      name = "testGauge",
      x = 100,
      y = 100,
      height = 40,
      width = 200,
      time = 10
    })
generated by LDoc 1.5.0 Last updated 2023-05-29 18:41:27