Thread Tools Display Modes
08/23/21, 06:46 PM   #1
HSBS_User
 
HSBS_User's Avatar
Join Date: Feb 2021
Posts: 8
Changes with Timer format strings/color codes

A couple addons I use have timer displays/countdowns. I'd like to make two changes for some elements of those timer formats:

1.) Hide the "s" text after the numerals when a timer is on seconds. (seconds are implied by pacing, I feel the "s" is unnecessary- keep "m" for minutes "h" for hours)

2.) Add a color call for numeral countdown depending on the remaining duration (under 4 sec count goes orange, under 2 sec- count goes red etc...)

The whole time format function is a little intimidating to me lol- still quite bad at lua and don't want to break any strings :x Anyone able to instruct me on how to achieve this/ point me in the right direction (other addons using this in their code I could just cannibalize?
  Reply With Quote
08/24/21, 02:16 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,963
I've moved your thread to the other forum "LUA/XML help" as this is more a lua request than an addon request.


Before changing the addons you should ask the authors if they can add this feature, else you'd have to do it again after each update of the addon. This can be frustrating, believe me
Please use the addon comments of these addons for this request, or if the author portal is enabled, the feature request button there.
-> Like described here: https://www.esoui.com/forums/showthread.php?t=9885

Changing the time format in ESO cannot be done that easy "for all addons". ZOs provides a few functions for it which have pre-defined formats. If you change the functions you will most likely break other addons, which rely on them.
If you do this locally for yourself, fine.
If you add it to addon code an release this: Please don't! Nobody wants to hunt for user reporting weird stuff caused by hidden overwritten functions.

Here are the time related functions of ZOs:
https://github.com/esoui/esoui/blob/...obals/time.lua
e.g.
ZO_FormatCountdownTimer
which internally uses ZO_FormatTime
So you need to define your own function like ZO_FormatCountdownTimer whch then formats the timer according to your needs.

ZO_FormatCountdownTimer e.g. checks for 3 seconds left and formats the tme differently. Your funcion needs to check for something <=60 seconds left and formats it your way then, as example.

Possible global constants for the time formating can be found inside the esouidocumentation_pxx.txt files linked at the Wiki's APIVersion history->current API version "live" (or PTS if you develop there):
https://wiki.esoui.com/APIVersion -> https://wiki.esoui.com/APIVersion#live_API_version -> "API TXT Documentation:" Downlaod linked txt file


e.g.
Code:
TIME_FORMAT_DIRECTION_ASCENDING = 0
TIME_FORMAT_DIRECTION_DESCENDING = 1
TIME_FORMAT_DIRECTION_NONE = 2
TIME_FORMAT_PRECISION_MILLISECONDS = 5
TIME_FORMAT_PRECISION_MILLISECONDS_NO_HOURS_OR_DAYS = 6
TIME_FORMAT_PRECISION_SECONDS = 0
TIME_FORMAT_PRECISION_TENTHS = 1
TIME_FORMAT_PRECISION_TENTHS_RELEVANT = 2
TIME_FORMAT_PRECISION_TWELVE_HOUR = 3
TIME_FORMAT_PRECISION_TWELVE_HOUR_NO_SECONDS = 7
TIME_FORMAT_PRECISION_TWENTY_FOUR_HOUR = 4
TIME_FORMAT_STYLE_CAST_TIME = 4
TIME_FORMAT_STYLE_CHANNEL_TIME = 6
TIME_FORMAT_STYLE_CLOCK_TIME = 11
TIME_FORMAT_STYLE_COLONS = 0
TIME_FORMAT_STYLE_COOLDOWN_TIME = 5
TIME_FORMAT_STYLE_DESCRIPTIVE = 7
TIME_FORMAT_STYLE_DESCRIPTIVE_MINIMAL = 14
TIME_FORMAT_STYLE_DESCRIPTIVE_MINIMAL_HIDE_ZEROES = 16
TIME_FORMAT_STYLE_DESCRIPTIVE_MINIMAL_SHOW_TENTHS_SECS = 15
TIME_FORMAT_STYLE_DESCRIPTIVE_SHORT = 8
TIME_FORMAT_STYLE_DESCRIPTIVE_SHORT_SHOW_ZERO_SECS = 9
TIME_FORMAT_STYLE_DURATION = 12
TIME_FORMAT_STYLE_RELATIVE_TIMESTAMP = 10
TIME_FORMAT_STYLE_SHOW_LARGEST_TWO_UNITS = 17
TIME_FORMAT_STYLE_SHOW_LARGEST_UNIT = 1
TIME_FORMAT_STYLE_SHOW_LARGEST_UNIT_DESCRIPTIVE = 2
TIME_FORMAT_STYLE_SHOW_LARGEST_UNIT_DESCRIPTIVE_COLOR = 13
TIME_FORMAT_STYLE_SHOW_LARGEST_UNIT_DESCRIPTIVE_SHORT = 3
Maybe that the constants ehre, adn tehf unctions of ZOs are not designed to make your wished format to work, you need to test this.

Last edited by Baertram : 08/24/21 at 02:39 AM.
  Reply With Quote
08/24/21, 04:09 PM   #3
HSBS_User
 
HSBS_User's Avatar
Join Date: Feb 2021
Posts: 8
Ah, thanks Bear

Wasn't sure what the etiquette/protocol was with this kind of a request. Authors have now been asked. Wouldn't even try changing functions of the kind you'd cited, had meant to just adjust settings within addons- fingers crossed said functions don't over constrain ones ability to format time text. Thank you for the links, may come in handy one day.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Changes with Timer format strings/color codes

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off