Closed phylll closed 2 years ago
MMM even reads those showplayers_barX
attributes to determine whether players should have read access to the barX
values... and still it never occurred to me to actually make them writable (by GMs).
Seems like a simple oversight that should be easily rectified.
Same goes for showplayers_name
.
For bar1
etc. there's actually several interacting token properties:
showplayers_bar1
playersedit_bar1
– "Allow controlling players to edit the token's Bar 1. Also shows Bar 1 to controlling players, even if showplayers_bar1 is false."Looks like that mysterious "something to control whether the bar's numeric value is shown to players on top of the plain bar" setting has been mystifying others as well:
https://app.roll20.net/forum/post/10330024/setting-token-bar-text-overlays-via-api
I suppose exposing something that covers showplayers_barX
and playersedit_barX
would still be useful for our use case.
I'm not terribly fond of the naming. Maybe bar1_shown
and bar1_edit
instead?
Speaking of showplayers_name
... there's actually two properties that sound like much the same thing: showname
and showplayers_name
. Plus, there's playersedit_name
.
Experimentation yields this:
showname |
showplayers_name |
editplayers_name |
GMs | controllers | others |
---|---|---|---|---|---|
false |
– | – | – | ||
true |
false |
false |
shown | – | – |
true |
false |
true |
shown | shown | – |
true |
true |
shown | shown | shown |
Did you have any trouble with tokens updating properly? When I tested this new feature, the bars never behaved they way I expected them to. Sometimes the properties seemed to be updated when I checked through the Roll20 UI, sometimes not immediately. Even logging out of the game and back it did not seem to help. Sometimes one bar disappeared and the other remained, even though I had set them all to false
.
This is the code I used:
!mmm script
!mmm for tokenID in selected
!mmm do setattr(tokenID, "bar1_shown", false)
!mmm do setattr(tokenID, "bar2_shown", false)
!mmm do setattr(tokenID, "bar3_shown", false)
!mmm chat: ${tokenID.name}'s bars reset.
!mmm end for
!mmm end script
Ah wait... sorry. All of this is only about what's shown to players, I just realized. So I always have to switch to player mode to see what's happening... oops.
Looks like that mysterious "something to control whether the bar's numeric value is shown to players on top of the plain bar" setting has been mystifying others as well:
https://app.roll20.net/forum/post/10330024/setting-token-bar-text-overlays-via-api
Maybe these folks were confused about the different elements of the UI? Is there some hope remaining that the API actually does expose all the relevant settings?
After some experimentation, I learned that there are two different parts of the token settings UI at play here.
view: true / false
edit: true / false
text overlay: hidden / visible to controller / visible to everyone
standard
: large bars, number overlays governed by the per-bar settings explained before, and compact
: smaller bars and no number overlays regardless of the per-bar settings where the text overlay dropdown is greyed outThe relevant combinations for me are these:
Token bar options / style | Token bars / barX / Player permissions & Text overlay | Player result: barX_shown / barX numbers |
---|---|---|
standard |
view /edit /hidden |
visible / hidden |
standard |
view /edit /visible for everyone |
visible / visible |
compact |
view /edit /(overlay permissions inactive) |
visible (smaller) / hidden |
Ultimately, what would help our GM would be a way for a script to batch-edit NPC tokens into compact
view with those two bars visible to everyone
.
I'll definitely expose the "compact bars" setting (probably as bars_compact
) and, while we're at it, the "bars location" setting as well (as bars_location
, valid values: "overlap_top"
, "overlap_bottom"
, or "bottom"
).
When I was looking into the settings I've already exposed (bar1_shown
etc.) I tried a bit of reverse engineering much like what's described in this thread: Dump values of all token attributes, change something, dump again, compare. Unfortunately I couldn't find anything that changed when I manually changed the "numbers overlay" option in the UI.
This could mean:
attributes
property, which appears to contain all attributes – certainly all that are documented)"campaign"
object attribute, but GMs' current page overrides are stored in a "player"
object attribute)Unfortunately I couldn't find anything that changed when I manually changed the "numbers overlay" option in the UI.
Did you find a change when you changed to "compact bars"? Since those override the bar-specific settings, that would be enough for my present (most basic) use case.
I didn't check that setting – only the "text overlay" ones. I assume the "compact bars" setting will work fine.
I may have spoken to soon: The compact_bar
token attribute exists (defaulting to JavaScript null
for all existing tokens) and I've reverse-engineered that its valid values are null
(standard size) and "compact"
(compact size)... but unfortunately even though I can set "compact"
in API code, setting it in API code doesn't affect the visuals.
I've read about similar effects with other API object attributes. Sometimes it's possible to work around this issue by setting the attribute to some intermediate value first to trigger an update. Some further experimentation may be warranted.
Arguably good news: bar_location
(alias bars_location
in MMM) works (though "overlap_bottom"
looks more like "obscure most of the token", and "bottom"
behaves exactly like "foo"
and looks like "vertically centered, horizontally anchored to the token center at the bars' left edge").
Ah, looking into TokenMod's source code I'm finding…
Valid bar_location
values are "above"
and "below"
(plus the two "overlap_
… ones) – not "bottom"
like the docs say
Nothing to suggest that compact_bar
has any issues being set; I'll try TokenMod and if that works where MMM doesn't, I'll figure out why exactly from there
I may have spoken too soon that I spoke too soon. compact_bar
works fine if you feed it the values it expects (i.e. "compact"
vs null
because why not?).
The "above"
and "below"
values for bar_location
also work fine.
Experimental support for the following token properties in our test game:
bars_above
~ bars_style_top
(boolean)bars_overlap
~ bars_style_overlap
(boolean)bars_compact
~ bars_style_compact
(boolean)I've slightly renamed the token properties (now available in our test game) – see edited previous comment. Sorry for the noise.
Check out the new %{MacroSheet|fixBars}
GM script that resets the token bars the way we want them for all NPCs (filtered by .character_id and not .PC
) on the current page. Works fine in our test game, I'll have the GM test it on the main game, as well.
I'll ask the GM once MMM 1.35.0+ is installed in the main game, I meant to say, of course. 😀
SpawnDefaultToken looks as if there are properties called
showplayers_bar1
etc. that determine if a bar is shown to, well, the players? A simple search forshowplayers_bar1
and then fortokenAttributes
in the code linked up above seemed to me that was the case. Would be useful to make these properties accessible astoken.showplayers_bar1
etc., so we could very quickly provide our GM with a script to fix every selected token's bar visibility settings.