A downloadable Foundry VTT package

Library for Foundry VTT which provides module developers with a means to modify the Ruler class in core Foundry VTT code, while reducing the likelihood of conflict with other modules. Also aims to make certain overrides of the Foundry ruler easier to accomplish.

Find out more from the GitHub page for libRuler.

Install to Foundry VTT with this Manifest URL.

Usage

The libRuler module overrides two functions of the Ruler Class: Ruler.prototype.measure and Ruler.prototype.moveToken. In doing so, the libRuler module deprecates Ruler.prototype._highlightMeasurement in favor of a nearly identical version of that function in a new Segmentclass. In order to track changed Ruler properties across users, libRuler wraps Ruler.prototype.toJSON and Ruler.prototype.update. All of these changes are implemented using the libWrapper module.

libRuler's version of Ruler.prototype.measure, at measure.js now creates a Segment representing the path between two waypoints (including origin or destination, as appropriate). The sequence of events remains the same, but events are now mostly handled by the Segment Class. This permits modules to wrap or otherwise modify sub-parts of the Ruler measurement flow without having to re-write the entire measure method.

Most modules will want to wrap functions for the new Segment Class. A Segment contains a link to the Ruler Class, a link to the prior segment in the chain, if any.

The code for moving a token using the ruler remains nearly the same as in core. Ruler Class gains a testForCollision method to confirm whether a collision has in fact occurred, and an animateToken method to actually do the token movement.

This allows Elevation Ruler, for example, to add elevation to the token as it is moved along the ruler path.

Leave a comment

Log in with itch.io to leave a comment.