util¶
Source: base/tealdef/scripts/util.d.tl
Notes
Types of /scripts/util.tl (Util): resolving script function references and formatting game-time
durations. Load it with local util = ug_require "/scripts/util.tl" as Util.
Util¶
record global base/tealdef/scripts/util.d.tl:3
global record Util
Load: local util = ug_require "::/scripts/util.tl" as Util
Notes
Miscellaneous script helpers returned by ug_require "/scripts/util.tl".
Functions
teal only extension of util --> call with util.funYouWannaCall(...) and util = ug_require "path/to/this"
useFn(string) : function base/tealdef/scripts/util.d.tl:5
Call as util.useFn(…)
No description in the game files yet.
Returns function
Used in the base game: 70 times in 29 files
base/content/game_mechanics/game_mechanics/notifications/gui/notification_log.tl:31
local dataStateFn = util.useFn(param.entry.notification.type .. "@useDataState") as (function(any, any) : NotificationGuiData)
base/content/game_mechanics/game_mechanics/notifications/gui/notification_popups.tl:62
local dataStateFn = util.useFn(params.notification.type .. "@useDataState") as (function(any, any) : NotificationGuiData)
base/content/game_mechanics/game_mechanics/notifications/notification_legacy_util.tl:71
base/content/game_mechanics/game_mechanics/notifications/notification_util.tl:152
base/content/game_mechanics/game_mechanics/notifications/notifications.script.tl:76
base/content/game_mechanics/game_mechanics/notifications/types/notification_react_util.tl:122
… and 23 more files.
formatTimePoint(number) : string base/tealdef/scripts/util.d.tl:6
Call as util.formatTimePoint(…)
No description in the game files yet.
Returns string
formatDurationWithCurrentCalenderSpeed(durationInDefaultSpeedMs : integer, integer, ?DurationRounding) : string base/tealdef/scripts/util.d.tl:13
Call as util.formatDurationWithCurrentCalenderSpeed(…)
Notes
Formats a duration as years, months and days at the current calendar speed.
| Parameter | Type | Description |
|---|---|---|
durationInDefaultSpeedMs |
integer |
Duration in milliseconds of game time. |
#2 |
integer |
The current millisPerDay of the GAME_SPEED component; 0 (calendar paused) formats the plain game time instead. |
#3 |
?DurationRounding |
Optional rounding mode; without it the result lists years, months and days. |
Returns string: Translated text such as "1 Year 3 Months".
Used in the base game: 27 times in 13 files
base/content/game_mechanics/game_mechanics/company/company_util.tl:216
remainingTime = util.formatDurationWithCurrentCalenderSpeed(math_util.round(remainingCooldown.remainingMs), millisPerDay)
base/content/game_mechanics/game_mechanics/finance/finances_cargo_lifetime.tl:70
text = labelInMilliSeconds == 0 and lang_util.formatInt(0) or util.formatDurationWithCurrentCalenderSpeed(labelInMilliSeconds, millisPerDayState:old(), "Month")
base/content/game_mechanics/game_mechanics/finance/finances_loan_gui.tl:45
base/content/game_mechanics/game_mechanics/notifications/types/notification_react_util.tl:43
remainingTime = util.formatDurationWithCurrentCalenderSpeed(math_util.round(params.progress.remainingDurationMs), millisPerDayState:old())
base/content/game_mechanics/game_mechanics/subventions/deliver_cargo/deliver_cargo.script.tl:337
base/content/game_mechanics/game_mechanics/subventions/deliver_cargo_town/deliver_cargo_town.script.tl:433
… and 7 more files.
Util.DurationRounding¶
enum base/tealdef/scripts/util.d.tl:8
enum DurationRounding
Notes
Rounding mode for formatDurationWithCurrentCalenderSpeed.
Used in the base game: 1 time in 1 file
base/content/scripts/scripts/util.tl:40