DC23 / jd-easytimekeeping

Easy timekeeping module for the Foundry VTT
https://foundryvtt.com/packages/jd-easytimekeeping
MIT License
3 stars 1 forks source link
dragonbane foundry-vtt role-playing-game rpg

Easy Timekeeping

GitHub Release Static Badge GitHub Issues GitHub Bugs GitHub Total Downloads GitHub Downloads (all assets, latest release)

Release Drafter Release Creation

Easy Timekeeping implements simple timekeeping without any fuss or complicated features. It's a lightweight, customisable, and easy to use timekeeping tool for any game. While general purpose, this module has some features that make it particularly suited to the Dragonbane game system. However, those optional features are turned off by default, and the Dragonbane system is not a dependency of Easy Timekeeping.

Easy Timekeeping has the following main features:

How Time is Reckoned

Easy Timekeeping splits each 24 hour day into 4 shifts:

Name Times Graphical Clock Appearance
Night 12am - 6am circular clock with 4 filled segments
Morning 6am - 12pm circular clock with 1 filled segments
Afternoon 12pm - 6pm circular clock with 2 filled segments
Evening 6pm - 12am circular clock with 3 filled segments

The name of each shift can be customised in the module settings. It's primarily used in the fuzzy time but may be used for other features in future.

The daylight cycle also splits the 24 hour day into 4 phases, called Dawn, Day, Dusk, and Night. With the default settings, these phases take place at the following times:

Phase Times Description
Dawn 6am - 7am Scene lighting transitions from night to day
Day 7am - 6pm Scene lighting is set to the day setting
Dusk 6pm - 7pm Scene lighting transitions from day to night
Night 7pm - 6am Scene lighting is set to the night setting

Of course, you can change the start times and the duration of both dawn and dusk in the settings, which can make the relationship between the daylight cycle phases and the four shifts quite wobbly. That's up to you!

The API

The Easy Timekeeping API can be accessed from Foundry macros with:

game.modules.get('jd-easytimekeeping').api

From macros, you can do everything that the UI allows - setting, incrementing, and decrementing the time.

The Time Change Event

Another way to interact with Easy Timekeeping is through the Time Change event. This is called whenever the time changes through any means - the UI or by the API. You can listen to the event from a World Script by subscribing to the time change hook. For example:

Hooks.on(game.modules.get(MODULE_ID).timeChangeHookName, (data) => {
    console.log(data)
})

If you don't want to mess around with world scripts, then as GM you can register a standard script macro in the module settings with the Time Change Event Handler setting. The registered macro will be called when the time changes. Unlike the hook, the data object gets exploded and your macro will receive the oldTime and time variables directly as globals.

oldTime and time (or data.oldTime & data.time in a world script) are timeAugmented objects.

A Few Thanks

I'd like to thank a few projects and communities, without whom this project probably wouldn't exist.

What Was That About SmallTime?

Inspired by the UI? Really, is that all? What about all the rest of it? That's the funny thing. I'd implemented my macro proof of concept, complete with day/night lighting cycle and was well underway on this module before I knew that SmallTime even existed. I arrived at the same idea independently. And since I wrote this module primarily as a way to teach myself how to write a Foundry module, it didn't seem to matter that it did more or less the same thing. Somewhere in the Foundry Discord is the conversation where I'm asking for ideas on how to write a UI for my timekeeping module and someone mentions the way that SmallTime does things. That's the first I'd heard of it. There followed a short period of disillusionment followed by the realisation that it simply doesn't matter. I had my own ideas for a new twist on things, so here we are.