Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Is there any way to change the page for the GM via API?

I found this earlier question where it seems this is not possible:&nbsp; <a href="https://app.roll20.net/forum/post/7371612/changing-the-gms-page/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/7371612/changing-the-gms-page/?pagenum=1</a> I'm hoping maybe something has changed in the meantime? I'm writing a script that fixes up module tokens for my friend, and for tokens that are in a weird state and need manual intervention I log an error indicating what's up. What I'm trying to actually accomplish is some way to take the GM directly to the token in question. So maybe there's some other way to handle that.
1681919815

Edited 1681919834
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Skippy! AFAIK, this is not possible. The GM exists in a space beyond the player flag. However... If you could write your script in such a way that a player could do whatever fixes are necessary (maybe using targeting), the script could function by having two browser instances open, The GM sends the player to the page in question, and then the gm switches to the player window and makes the fix. However, this might be an A/B problem. What are you actually trying to accomplish? There might be other ways of achieving that goal.
X/Y problem is why I included what I actually want to accomplish: automatically selecting a specific token. Just to provide a bit more detail, what my script is mainly doing is fixing up the Wizards modules to have HP in bar3 by default. That's because bar3 is shown first, not bar1. (A couple of unverified assumptions on my part: you can't make bar1 show first? And also my friend said if you change the bar colors, it won't change for everyone?) I'm also adding in the passive_wisdom on bar2, since that's how we like to run. So the tokens would have "r/g/b" bars set to "hp/ac/wis percept". I also make sure the HP/AC/Wis bars get linked to the actual attributes for named NPCs, and unlinked for unnamed NPCs. This is so that named NPCs will always have the correct HP shown on any map, instead of having "per token" HP. Unnamed NPCs get everything unlinked (npc_ac seems to be linked by default), so that tweaks to those monsters on the fly won't affect the underlying monster at all, just that one token instance. Because I'm making so many changes to the tokens, I'm verifying that everything is in exactly the state I expect it to be by default. So for example, I ran into one instance where a token just seems to be outright bugged in the Wizards module. It has its HP bar set to be 104 of 14, and 104 is the actual correct max HP. So it looks like a 0 just got dropped by accident. All those weird tokens get logged, with details printed out on what's unexpected. So what I'm trying to do is make it easier to hunt that token down to see if it's ok to change or not, and manually intervene if needed. Currently I just print the page name and token coordinates for that purpose. I just want to make finding the token super easy and fancy with a one click button. :)
P.S. next script adventure on the docket is seeing if I can automatically fix the Wizards modules that were built before doors existed to add in the doors where they should go. :)
1681920682
The Aaron
Roll20 Production Team
API Scripter
As Keith said, switching pages for a GM is not possible.&nbsp; You can place them on a page as a player (either the ribbon or splitting the party) with the API, but that will only affect where they are when they are logged in as a player. As for their view, you can ping-pull them to see a specific place on the map page, but be aware that you'd only want to do that if they are actually on that page.&nbsp; Here's a function that takes care of the details around finding what page a player is on, including a GM: const getPageForPlayer = (playerid) =&gt; { let player = getObj('player',playerid); if(playerIsGM(playerid)){ return player.get('lastpage') || Campaign().get('playerpageid'); } let psp = Campaign().get('playerspecificpages'); if(psp[playerid]){ return psp[playerid]; } return Campaign().get('playerpageid'); }; For GMs, the last page they loaded will be stored on the player object, with the caveat that if they have never changed pages (first time ever entering a game), or they are loading pages in two different browsers at the same time, the page might not be accurate.&nbsp;&nbsp;
1681920795
The Aaron
Roll20 Production Team
API Scripter
skippy said: P.S. next script adventure on the docket is seeing if I can automatically fix the Wizards modules that were built before doors existed to add in the doors where they should go. :) Pretty sure Scott C. is building this into his doors script, but definitely something you could dig into if you want!&nbsp; Note that doors and windows use a different coordinate system than other objects, so you'll need to do some conversion.&nbsp; Basically, door x = line left and door y = - line top.
The Aaron said: skippy said: P.S. next script adventure on the docket is seeing if I can automatically fix the Wizards modules that were built before doors existed to add in the doors where they should go. :) Pretty sure Scott C. is building this into his doors script, but definitely something you could dig into if you want!&nbsp; Note that doors and windows use a different coordinate system than other objects, so you'll need to do some conversion.&nbsp; Basically, door x = line left and door y = - line top. Thanks for the heads up! I'm a software developer by trade, but only just started looking at roll20 scripts two days ago so I have a lot of catching up to do.
You mentioned ping-pull, I'll have to try that out but need to head out for awhile right now. Do you happen to know off-hand if that would work for the GM view? If it does, the GM would only have to navigate to the correct page, and then I could ping-pull them to the token of interest. I'm guessing ping-pull also only works for non-GM players though...?
1681923139
The Aaron
Roll20 Production Team
API Scripter
It does!&nbsp; Here's the code I use for pulling all GMs to the token with the current turn in TurnMarker1 (slightly modified): const getGMPlayers = (pageid) =&gt; findObjs({type:'player'}) .filter((p)=&gt;playerIsGM(p.id)) .filter((p)=&gt;undefined === pageid || p.get('lastpage') === pageid) .map(p=&gt;p.id) ; const sendGMPing = (left, top, pageid, playerid=null, moveAll=false) =&gt; { let players = getGMPlayers(pageid); if(players.length){ sendPing(left,top,pageid,playerid,moveAll,players); } }; And called like this: sendGMPing(obj.get('left'),obj.get('top'),obj.get('pageid'),null,true); Note the filtering on pageid.&nbsp; If I remember correctly, if you ping pull someone, it will pull them to the location on whatever page they are on, but not show the concentric rings.
1681923215
The Aaron
Roll20 Production Team
API Scripter
skippy said: Thanks for the heads up! I'm a software developer by trade, but only just started looking at roll20 scripts two days ago so I have a lot of catching up to do. Being new to the API, some of these discussions might be helpful: <a href="https://app.roll20.net/forum/post/6605115/namespaces-novice-seeks-help-exploring-the-revealing-module-pattern" rel="nofollow">https://app.roll20.net/forum/post/6605115/namespaces-novice-seeks-help-exploring-the-revealing-module-pattern</a> <a href="https://app.roll20.net/forum/post/6584105/creating-an-object-that-holds-specific-character-dot-id-and-character-name/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/6584105/creating-an-object-that-holds-specific-character-dot-id-and-character-name/?pagenum=1</a> <a href="https://app.roll20.net/forum/post/6237754/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6237754/slug%7D</a> Feel free to ask if you have any questions!
Thanks for the links! I'm actually pretty new to roll20 (just the last couple months as a player), and have literally zero knowledge about the GM tools. So I'm pretty much just going off what my GM friends ask for. I have a lot of domain knowledge to pick up, and will probably run into lots of X/Y problem type stuff while I learn. ☺️
1681939792

Edited 1681941158
timmaugh
Forum Champion
API Scripter
On a slightly related note, SelectManager has a way to select tokens for you automagically (virtually selecting them), which works if you're already on the same page... and Fetch can retrieve data from a token whether or not you're on the same page, provided you supply the token_id. As an example of the latter, here's an example using Fetch and ZeroFrame &nbsp;to output a template of information about a given token: !&amp;{template:default}{{name=Report for @(TheToken.token_name)}}{{Bar1=@(TheToken.bar1_name[(none)]) (@(TheToken.bar1)/@(TheToken.bar1_max))}}{{Bar2= @(TheToken.bar2_name [(none)] ) (@(TheToken.bar2)/@(TheToken.bar2_max)) }} {{Bar3= @(TheToken.bar3_name [(none)] ) (@(TheToken.bar3)/@(TheToken.bar3_max)) }}{{Page=@(TheToken.page_name)}}{{Location=(@(TheToken.left),@(TheToken.top))}} {&amp;simple}{&amp;global ([TheToken]-MYoplGxUFiHAOpm5x5f)} Then, if you had a script to handle the ping pull, you could have a template line that would include a button to execute that script and ping-pull to the designated token. I ran out of time, otherwise I'd have poached some of Aaron's code, above, and cobbled something together. Maybe later tonight... EDIT : Forgot a screenshot of the above command:
Thanks! I was wondering if it'd be possible to actually select a token like that, and not just pull it into view. Having the buttons is what I'd like to eventually get to for a "final final" version that I could maybe share with others. I'm planning to use status markers to indicate what you'd like to do with "weird" tokens, e.g. "green circle" to accept the weirdness and modify as-is, or "red circle" to ignore the token entirely and no longer examine it. Having a "go to token" button, and also "auto fix" and "manual fix" buttons that mark the appropriate status is my ideal scenario. With those buttons included on each of the messages I send describing whatever's weird about the token.
Ohhhhh, I like that screenshot you just linked. :)
1681941428
timmaugh
Forum Champion
API Scripter
Yeah, SelectManager can select the token "virtually" -- for the purposes of a message taking action against the token. It won't show as selected on the VTT, but if you had a series of buttons that all were created using the Token ID in a {&amp;select} statement, they would always be set up to act on that token: [Some label](!&amp;#13;!yourscript --todo|foo {&amp;select&nbsp; -MYoplGxUFiHAOpm5x5f }) There might be a trick about having to get the {&amp;select} tag to survive through the message that would create the button so that it still exists in the command line when the button is executed (since that's when you want the token to be "selected"). I'll play with it later to see what has to be done.
1681948735

Edited 1681948864
Just encountered something interesting with the pull ping, it didn't move the background map for me. So it looked like all of my tokens just moved, but it was really the background itself failing to move that I was seeing. An F5 put things back in order, but everything looked pretty f'ed up until I did. ☺️ (this was just a random occurrence, it seems to work most of the time) And now that I think about it, we've seen that in normal play too. Where the background position gets out of sync for some of us, and then tokens look like they're in the wrong spot.
1681953673

Edited 1681953701
I was able to get the core functionality of my script working (minus fancy buttons) and ran it through Mad Mage and Phandelver. It sets the HP/AC/Percept to the bars we prefer, and makes sure&nbsp; that &nbsp; the named NPCs have those stats linked directly to their character sheets, and that unnamed NPCs don't have anything linked. There were a handful of tokens to review by hand, the ping pull made that easy. Most of the tokens were fine to accept (e.g. boosted HP on "named" monsters that aren't actual named NPCs). Some were just dead creatures that were missing the red X status marker. A few were actual "bugs" in the module, where there was e.g. a typo in the max HP. Or where the "young, non-combat" versions of some monsters had their stats mostly deleted, but one or two tokens got missed and still had a stat lingering. Those I just fixed up by hand. Still lots to do to tidy things up and make things a bit easier, but I'm fairly happy with the initial iteration of my first ever script. :)