The main function is called at script invocation, which is nice and early
but everything we do is done in hooks.
This makes it not really useful, and harder to properly disable the module
with the settings.
So, register our `init` hook at script invocation and call the main function
from within.
This makes handling the disabling via the setting trivial, and ensures that
*everything* is properly disabled.
However, the `socketlib.ready` hook fires earlier than the `init` one, so
register the socket at invocation as well, but only register the remote
methods in the main function.
When changing scenes, *a lot* of data is either empty or points to
the previous scene, preventing us from knowing whether a token is in
combat or not directly from the token.
To work around that, go through the list of combats directly and try
to match them with the scene and token we are drawing instead of using
`.inCombat`.
We cannot rely on `game.combats.active` either as it points to the
active combat in the previous scene.
This is far more work, but it is the only working solution I found.
It depends quite a bit on Fabula Ultima's system combat type which
lists combatants.
This leaves a more minor issue that the borders are not updated when
switching between encounters on the same scene, but this is a rarer
scenario.
Remove the issue from the README and mention the encounter switch issue.
In the Fabula Ultima system, the clients cannot
use the combat hooks, only the GM.
So the GM orchestrates the token visiblity changes
for all clients.
Currently, the GM checks the status of tokens when
they run the combat hook.
However, this doesn't work when the GM is on another
scene, as the tokens *do not exist* for their client
in this case, as only those in the current scene do.
To fix this, we need to do the token status check
on all clients, and verify that we are on the proper
scene : otherwise there won't be a token to update.
Change the method called on the clients by the GM
to be a wrapper around token_set_border_visibility()
which checks the scene and the token locally.
Introduce another method to manually set the border
status on clients via SocketLib, used for the end of
combat.
Remove the mentions of this issue in the README and
comments as this commit fixes it.
The point of the module is to allow multiple functionalities
to support our campaign.
They might not be suited all the time or to all of them.
They might be buggy !
Add a toggle setting to the dynamic borders functionality,
so that we can keep the compendium while it is fixed.
This initial version adds a custom compendium with a
macro for the tinkerer, and a dynamic token border
to track player turn status.
It has a couple of known major bugs but is needed for
an upcoming game, with fixes hopefully later.
It is only compatible with Foundry v12 at this time.