manipulating selection

1528667708

Edited 1528667798
Ammo
Pro
It appears that the selection/deselection of tokens is done strictly at the UI layer and the API cannot manipulate it.  Is this correct? If so, has anyone studied how selection works in detail to see if maybe injecting something in the client UI (obviously only on your own browser) via GreaseMonkey could be used?   Yes, this would require some communication via the client-side code reading the chat I guess since you can't open up other connections to the sandbox, or at least that's what I think. I really would like to select groups of tokens automatically on some events.   
1528668838
Scott C.
Pro
Sheet Author
API Scripter
Can't comment on your proposed solution, but yes, the API doesn't interact with selection in way other than telling what you have selected when sending a chat message
1528672025
The Aaron
Pro
API Scripter
Leaving selection aside, what is the problem you're trying to solve?
1528716055
Ammo
Pro
I wrote a lot of API script to automate "the way I use Roll20" and being able to store selection sets is the next thing I would like to do.  Basically, I just need my scripts to be able to set the selection state of tokens.   This isn't rocket surgery, but since you can't just AJAX from the sandbox to the client side and twiddle the selection in the UI layer, it is non trivial.   I am wondering if anyone has done this already.   I'm less interested in someone telling me that I shouldn't be doing that, because that's less fun.   :)
1528721245
The Aaron
Pro
API Scripter
Sure, I was just curious what you would do with the selection if you achieved it. The “why” you’re trying to meet, rather than the “how” you’ve come up with to meet it. 
1528731421
Ammo
Pro
Here's an example of a flow that I would use: - initiative is on token that is marked as in command of a group of other tokens - character for that token commands all its dependent tokens to fire - <here I would set current selection to dependent/commanded tokens based on script storing the token relationships> - now the GM has the opportunity to remove/add tokens to the set based on circumstances in the scene - then the GM would click on a token action button for all those tokens to trigger their fire action I want to work through the selection instead of just having the script automatically fire all the dependent tokens because that takes the GM out of the loop.  I prefer the Roll20 way of keeping the GM in the loop thoughtfully, instead of the FG way of automating everything. I would use this same infrastructure to have various tokens that represent groups of other tokens, for group initiative, command structure, or whatever else I want to do.  The UI does not have the concept of persistent selection groups (just finished reading the client side code) but it would be pretty doable to tunnel a set of IDs to the client through hidden chat messages and then call the appropriate client-side code to manipulate the selection. 
1528732540
The Aaron
Pro
API Scripter
Interesting.  Sounds neat if you can get it to work. If you can't, I have some ideas how you could get similar behavior without it.