Closed michael-buschbeck closed 3 years ago
Table scale is available through the page
object API (see docs) as these two properties:
scale_number
scale_units
– one of ft
m
km
mi
in.
cm
un.
hex
sq.
or any custom labelI was thinking to provide conversion support (e.g. "give me these dimensions in meters" even if the page is measured in feet), but given the availability of under- and undefined units that may not be possible. (But I can still convert from pixels to "map units" and back and also provide access to the map unit name itself.)
Thanks! I think it makes sense to assume that the page is measured in the unit we need for whatever the macros do that are executed on that page -- if we're fighting according to Midgard rules which work in meters, the GM will scale the page in meters since otherwise we won't be able to use the Roll20 measurement tool to understand distances correctly. These might vary within the same game, e.g. meters for combat and kilometers for overland travel. So if MMM gave me access to the conversion factor between pixels and the current scale_unit
, that would seem completely sufficient!
There appears to be also a page
property called snapping_increment
which seems to be useful in this regard, see https://app.roll20.net/forum/post/9007178/help-getting-token-coordinates-using-selected-and-target/?pageforid=9007685#post-9007685
Interesting… so the scale
properties are in units of snapping_increment
(times grid unit = 70 pixels)?
Gotta play around with those settings to get a grip on this.
So if MMM gave me access to the conversion factor between pixels and the current
scale_unit
, that would seem completely sufficient!
Yeah, that makes sense.
I'll do that and provide the unit separately for good measure – if anyone wants to convert feet to meters, they can do it themselves.
Playing around yields this insight (consistent with the forum posting linked above):
snapping_increment
scale_number
gives the number of measurement units per grid cellscale_unit
is purely visualSo:
scale_number
/ (70 snapping_increment
)snapping_increment
) / scale_number
The docs are significantly confused about what constitutes a "[grid] unit" and what a "grid cell" – the interpretation that matches observation is that a "[grid] unit" is fixed at 70px, which however makes the documentation of scale_number
wrong ("distance of one [grid] unit" – no, of one grid cell).
Slight twist: If the GM disables snapping, snapping_increment
gets set to zero, but distances act as if it was 1
.
The
left
andtop
attributes are given in (unzoomed) pixels, but sometimes (or even most often?), in-game are of greater interest.Provide a way to convert between pixels and in-game dimensions.