PDA

View Full Version : Where is "Mask Sensitive Visibility" defined?



SilentRuin
November 23rd, 2020, 02:20
I have a token placed in the map via an extension and it turns out players can see it across LOS. If you right mouse on it you get this unlocked eye icon that says "Mask Sensitive Visibility" which if you set to the locked will do what I thought it always did - respect the LOS for players. My question is - how can I force this to always be defaulted to on? For sure I don't see this default on regular tokens as an option - and they respect LOS. The PC and NPC tokens also have this as the default and respect LOS. I tried to look up the menu click code based on the menu strings in 5E and CoreRPG source but could not find it. How does this work? How can I make my dropped token respect LOS for players? Also when its set its not remembered between sessions.

SilentRuin
November 23rd, 2020, 03:47
It appears the default for tokens placed by the system is a lock image with text "Set Always Visible" which when selected show an unlock image with text "Mask Sensitive Visibility". In my dropped token the default is the unlock image which is opposite of PC/NPC/Asset token default. I want to make mine the same - but don't understand how I can do this.

For sure this setting is not stored between sessions even for PC/NPC/Asset tokens (if I toggle it to the unlock image it will not remember it next session - just like my token will not remember if I toggle it to lock image). At the very least I want to force it to default to the lock image.

SilentRuin
November 23rd, 2020, 04:44
Another Clue. Ok for sure the DB has the <visibility>mask</visibility> tag in the <layers> that represents the appropriate default setting. Naturally, editing this and restarting FGU does absolutely nothing to the already placed token - no idea why. If I take where I create my tokeninstance and call the setVisible(true) (https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4129051/tokeninstance#setVisible) and change it to setVisible(false) - the <visibility> is set to mask in the DB and the default when I drop a new token in the map is the correct default. AND ITS INVISIBLE (sigh). I wanted it to place visible. So I then have to set another right mouse visibility flag using the exact same text - but different token image (slightly) and position in the menu, to make it visible - as in not greyed out. And it does not remember that one between sessions either.

I'll keep flailing at this but I really don't understand what this is doing with two flavors of visibility neither of which are remembered across sessions. And while the tokeninstance.setVisible sets both of these flags at same time I've yet to find a discreet one to set them both individually. Still experimenting. Hopefully in morning someone has taken pity and explains these visibility flavors and how to set them in the code.

SilentRuin
November 23rd, 2020, 05:33
And a solution - of sorts. While I can never make anything with visibility for a token store between sessions I can get the two visibility flags to be set how I want for default.

I originally had

newTokenInstance.setVisible(true);

Thinking that it would make token visible to the players. And it will. It will also make it so that it will always be visible even with LOS. These are two different flavors of visibility set by this (though its not in the document).

I then tried

newTokenInstance.setVisible(false);

This did make it no longer visible in LOS. But it was also no longer visible to the players.

So looking at all instances of setting visibility in the code I noticed a weird case for deleting them. I figured what the heck - right? Its not a documented arguement but may as well try it.

newTokenInstance.setVisible(nil);

Yeah. This worked. Got me visibility to the players but not visibility through LOS situations.

Recorded for posterity. Though I don't have the slightest clue why. Its possible not even calling this would be a similar fix but I'm going to go with this.

Still can't change either visibility flavor on a token and have it saved. No idea why.

Moon Wizard
November 23rd, 2020, 17:41
Good work figuring out. It's used in CoreRPG that way. Visibility is a 3-state variable (always visible, always invisible, mask-sensitive visible).

I've updated the wiki documentation for this function as well.
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4129051/tokeninstance#setVisible

Regards,
JPG

SilentRuin
November 23rd, 2020, 17:48
Good work figuring out. It's used in CoreRPG that way. Visibility is a 3-state variable (always visible, always invisible, mask-sensitive visible).

I've updated the wiki documentation for this function as well.
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4129051/tokeninstance#setVisible

Regards,
JPG

I was asked by a user of my extension if there was any way to insure tokens remembered what <visibility> was being set. Changing the DB has no effect on the token coming up in a new session - and its not updated in DB after a particular token is set to one of those states. Always comes back in as the token was placed. That's true for NPC token, PC token, Asset token, or my token. I'm guessing there is some reason its not possible to store it between sessions - was just wondering what that was.

Moon Wizard
November 23rd, 2020, 18:42
Visibility should be remembered between sessions; so that might take some investigation to see what is happening.

My initial guess might be that TokenManager script in CoreRPG is changing token token parameters in the Token.onAdd handler (which could affect visibility settings); but I thought it ignored tokens that were not linked in combat tracker or party sheet.

Regards,
JPG

SilentRuin
November 23rd, 2020, 19:02
Visibility should be remembered between sessions; so that might take some investigation to see what is happening.

My initial guess might be that TokenManager script in CoreRPG is changing token token parameters in the Token.onAdd handler (which could affect visibility settings); but I thought it ignored tokens that were not linked in combat tracker or party sheet.

Regards,
JPG

Well I do use the onAdd for my specific unique token - but nothing I know of uses any global version of that type of thing. For sure I turned off all extensions and did a raw test with a Single PC on a map. Right moused and clicked visibility then turned off one of the visibility options. It was not remembered when I came down and back up in FGU. True for any map token.

Its not a big deal to me as I can't imagine ever setting anything outside of the defaults. But someone asked so there must be some use to them.

Moon Wizard
November 24th, 2020, 16:39
I just double-checked by creating a brand new empty image, adding 3 tokens from Assets window directly, setting each to one of the 3 different visibility states, exiting, verifying the data in the db.xml tracked the visibility information, reloading campaign, and verifying that the visibility data was maintained for those 3 tokens. So, it looks like everything is working as intended by default.

Of course, if a script overrides for a specific token (such as CT-linked tokens) by calling setVisible API, then it would set to whatever the API call specifies.

I just wanted to double check, since you raised the initial concern.

Regards,
JPG

SilentRuin
November 24th, 2020, 18:06
I just double-checked by creating a brand new empty image, adding 3 tokens from Assets window directly, setting each to one of the 3 different visibility states, exiting, verifying the data in the db.xml tracked the visibility information, reloading campaign, and verifying that the visibility data was maintained for those 3 tokens. So, it looks like everything is working as intended by default.

Of course, if a script overrides for a specific token (such as CT-linked tokens) by calling setVisible API, then it would set to whatever the API call specifies.

I just wanted to double check, since you raised the initial concern.

Regards,
JPG

I assume by image you mean what I would call a map? I admit I'm stumped on this. The PC still does not remember any right mouse visibility lock icon I change (tried the top one again just now) - but the NPC does seem to remember. And placing a dumb chest asset (no extension intelligence for token) I can't even get visibility to show on it. So that must have only been available with tokens linked to the DB? I'm a bit confused by this.

There is no console log error about it failing to update that <visibility> tag in layers. But it for sure is not updating - and this with extensions or without extensions for the PC and chest asset tied to DB (map parcel extension created it).

This is FGU 5E ruleset. I'm wondering if anything with an active tokeninstance.onAdd sort of thing has this issue? Or simply that the token was ever touched with an extension even if its not currently running that extension?

For sure an NPC dropped into image with no extensions remembers the visibility setting - but for some reason the other stuff does not. A raw asset dropped in seemed to just give me the image right mouse wheel - or I was missing its activation area some how.

If you can place a PC/NPC and it remembers the settings between sessions - which are intelligent tokens tied to DB like mine - then I don't know what is going on. I never noticed this stuff till someone else mentioned it to me, because I will probably never set the visibility on these things.

Basically I'm just confused.

Moon Wizard
November 24th, 2020, 20:37
If you're using PCs that are linked to the combat tracker, then the visibility is controlled by the global TokenManager scripts. (And thus, it will get reset to what the scripts think it should be every time.)

Regards,
JPG

SilentRuin
November 24th, 2020, 21:01
If you're using PCs that are linked to the combat tracker, then the visibility is controlled by the global TokenManager scripts. (And thus, it will get reset to what the scripts think it should be every time.)

Regards,
JPG

That makes perfect sense. While I'm not sure why a token that is linked to DB, is in the map, and not on combat tracker is doing the same thing (are all those maybe doing something similar?)

Moon Wizard
November 24th, 2020, 21:06
They shouldn't unless there is a script that has registered to listen to add events; and is doing something. (i.e. that's what the TokenManager script does for any tokens it recognizes as linked to CT.)

JPG

SilentRuin
November 24th, 2020, 21:46
They shouldn't unless there is a script that has registered to listen to add events; and is doing something. (i.e. that's what the TokenManager script does for any tokens it recognizes as linked to CT.)

JPG

Not sure what registering to add events would look like. In my polymorphism I call TokenManger calls directly but don't override anything. And in Map Parcel I basically just call the tokeninstance stuff and don't touch TokenManger at all. And that pesky Death Indicator thing I didn't write but manage for community has tons of calls into TokenManager - but I don't see anything that looks like an override or register of them.

Is there a particular call that I can search for that would indicate what your talking about might be happening?

Also, I feel like you've spent too much time with me here so don't feel you have to answer. I don't use these visibility settings or plan to now that defaults are correct. It's more a "understand it in case there is a bug buried in my code" sort of thing that is preventing this weird setting from getting updated across sessions.

bonnieshona
November 26th, 2020, 14:40
Tokens can have 3 different visibility states: always visible, always invisible and mask-sensitive visibility. With mask sensitive visibility, the token is only visible if the center of the token is in an unmasked region of the map.

For CT-linked tokens, PC token visibility defaults to always visible, and NPC token visibility can be toggled through the GM combat tracker between always invisible and mask-sensitive visibility. For other tokens, the default visibility is mask-sensitive.

To manually set the visibility of a token, right click on the token and select the Visibility menu option you desire.

SilentRuin
December 2nd, 2020, 04:24
Good work figuring out. It's used in CoreRPG that way. Visibility is a 3-state variable (always visible, always invisible, mask-sensitive visible).

I've updated the wiki documentation for this function as well.
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGU/pages/4129051/tokeninstance#setVisible

Regards,
JPG

Just got notified that something has changed in last three days where the token tied to the DB I placed (based on previous conversation) now appears invisible to players. Setting it to Invisible always seems to be only way to fix it but then we are back to the problem of seeing it no matter where it is on the map. What changed? How do I fix it now?

The following is the code that worked until about 3 days ago (placing token shows it visible). Need to know what I need to do to get it placed visible to players within LOS rules again (which was working).



if newTokenInstance then
newTokenInstance.setTargetable(false);
newTokenInstance.setActivable(true);
newTokenInstance.setActive(false);
newTokenInstance.setVisible(nil); -- had to experiment around to get the two flavors of visibility defaulted the way I wanted them. Visible to players but not through LOS.

newTokenInstance.setName(DB.getValue(nodeParcel, "name", ""));
end


Post Edit: I can also see it if I turn off LOS for the map. With LOS it is invisible no matter where it is on the map with regards to the characters. So I think something in LOS has changed.

Moon Wizard
December 2nd, 2020, 07:11
There's an issue where tokens added from outside CT drag are not always showing on player clients (i.e. added by extension or direct from Assets bag). There is a fix queued for the next release build.

Regards,
JPG

SilentRuin
December 2nd, 2020, 14:12
There's an issue where tokens added from outside CT drag are not always showing on player clients (i.e. added by extension or direct from Assets bag). There is a fix queued for the next release build.

Regards,
JPG

Excellent - thank you very much!