Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
But I want to report the delay of this timer object.
Your script is,
local timeDelta = os.time() - startTime
countdownRemaining = countdownRemaining - timeDelta
updateDisplayButtons()
startTime = os.time()
And I see that there is a gap between os.time() for timeDelta and os.time() for startTime.
So, the later "startTime" is very slightly delayed compared to the time for getting timeDelta.
This causes some inaccuracy in the measurement.
As the result, this timer becomes a little slower compared to the real time.
If the PC's performance is low, the problem becomes more severe.
So, I propose this,
local nowTime = os.time()
local timeDelta = nowTime - startTime
countdownRemaining = countdownRemaining - timeDelta
updateDisplayButtons()
startTime = nowTime
I think it could be the solution.
Thank you.
But there is one issue you might want to consider adding to yours. The way you add delta times together adds a fair bit of error in how long the timer runs (in my limited testing about 10%).
The solution is to keep the start time constant (only updated during pausing), and calculate time left based on current time and the timer length.