PDA

View Full Version : API calls to remove "token selection" ?



celestian
June 10th, 2019, 17:48
I've been fiddling around with some highlighting/indicators in the combat tracker. One thing I noticed is that there is apparently no way to "remove selection" of a token. I do not me "target" for another token I mean when you click on a token and select it.

I'd like to be able to clear the token select when it's another person's turn. The reason being is that I will select a token during one npcs turn, next round another npc goes and the "selected" token is from the previous turn selection and if I target something, for what I think is the current npc, it will actually target for the previously "clicked on/selected" token. To clear up that problem I'd like to just clear selection.

tldr; selecting a token persists, I'd like to clear selection on each turn.

Am I missing something and there is a API to allow you to clear the token selection?

Trenloe
June 10th, 2019, 17:52
It's based off the image control, not an individual token: https://www.fantasygrounds.com/refdoc/imagecontrol.xcp#clearSelectedTokens

celestian
June 10th, 2019, 17:56
It's based off the image control, not an individual token: https://www.fantasygrounds.com/refdoc/imagecontrol.xcp#clearSelectedTokens

AH! Perfect, I knew there had to be something. Thanks!

celestian
June 10th, 2019, 19:02
Okay, so I've implemented the clearselections and it "seems" to do something but not everything.

Here is the token before selection.

https://i.imgur.com/fxrCdtY.png

Here is the token AFTER selection.

https://i.imgur.com/ytYyggJ.png

And here is the token after the clear has been initiated.

https://i.imgur.com/d702de3.png

You'll note the token does appear to be unselected however it still seems to be acting like it is. You can see it even it showing the indicator for range to it's target. If I immediately "control-click" another token to target it adds those targets to that token. I needed to auto-select the "active" token as well.



-- clean any selected token, select active one
function clearSelectionToken()
local nodeCT = getDatabaseNode();
local tokenMap = CombatManager.getTokenFromCT(nodeCT);
local imageControl = ImageManager.getImageControl(tokenMap, true)
imageControl.clearSelectedTokens();
imageControl.selectToken( tokenMap, true ) ;
end


That seems to be working on client and host side.

damned
June 10th, 2019, 23:34
Please dont change the way Targeting works....

As GM in large battles I will try to do as much targeting as possible whole the PCs are taking their turns so that i can fire off my attacks on the NPC turns without slowing things too much.
In more cases than not an NPC will attack the same target they attacked on their previous turn - not always but certainly more often than not...

celestian
June 11th, 2019, 00:27
Please dont change the way Targeting works....

As GM in large battles I will try to do as much targeting as possible whole the PCs are taking their turns so that i can fire off my attacks on the NPC turns without slowing things too much.
In more cases than not an NPC will attack the same target they attacked on their previous turn - not always but certainly more often than not...

I'm not changing targeting, just token selection. It sounds the same but it's not. Token selection is the token you've clicked on, it shows the black ring when you do, that's it. When you target (control-click) that is targeting (which shows on the CT entry with each name of targeted tokens), that I did not change.

damned
June 11th, 2019, 01:23
I'm not changing targeting, just token selection. It sounds the same but it's not. Token selection is the token you've clicked on, it shows the black ring when you do, that's it. When you target (control-click) that is targeting (which shows on the CT entry with each name of targeted tokens), that I did not change.

Gotcha.