I was just wondering if there was a more efficient or at minimum neater way of writing the seconds of the day, rather than local day = 86400
This is more of a personal preference thing, but I am curious. Thanks!
if you are using these constants in many scripts you could create some module script that stores different constants for different time frames and reference these values through the module when needed, so that you dont need to keep redefining them.
example module script:
local timeModule = {}
timeModule.DAY_SECONDS = 86400
timeModule.HOUR_SECONDS = 3600
return timeModule
example usage:
timeModule = require(game.ReplicatedStorage.TimeModule)
print(timeModule.DAY_SECONDS)
1 Like
I always use math for it in my code:
60 (seconds) * 60 (minutes) * 24 (hours) aka 60 * 60 * 24
And then name the variable appropriately (e.g. secondsInDay)
local secondsInDay = 60 * 60 * 24
Plus side is you can configure it to other units as needed.
4 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.