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 .
×
May your rolls be merry + bright! 🎄
Create a free account

How can the API find out what page the GM is on?

1448513165
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
First I will ask my specific question, just to find out, then I will explain my use case so somebody can tell me I don't need to do it that way. (1) The campaign object has playerpageid and playerspecificpages to tell you what page most of the players are on, but a GM, when he on a different page just by clicking on it in the page toolbar. This does not seem to update playerspecificpages.  So is there any way for the API to know what page the GM is looking at? (2) My specific use case, is that I would like the API to be able to find all instances of a particular characters token on a page.  so if the API gets a message, it can use msg.playerid to see who pushed the button, then look for that player in playerspecificpages, and assuming it does not find it, the player is obviously on playerpageid. Unless it is the GM who is working on setting up a new page and is on a different page. Once I get the correct pageid, I can call getobjs with type token, pageid, whatever, represents charID.  So what if it is the GM and he is not on playerpageid?
1448515760
The Aaron
Pro
API Scripter
There isn't a way to tell (though I've mentioned it to Riley).  The best you can do is infer based on actions occurring on pages that could only be the GM (not the player page, not a player specific page).  Some scripts require the GM to move himself to a player specific page to be active (some of Stephen S.'s dungeon building scripts). When you mention a button, are you talking about a Token Action?  When a player clicks one of those, they must have a token selected, and you can get it from the msg.selected property.  That allows you to know who did it from msg.playerid and what they did it to from msg.selected.
1448518263
Chris D.
Pro
Sheet Author
API Scripter
Compendium Curator
Yes, I got that far already. To go into more detail of what I am attempting... I have some (many) buttons on my Earthdawn character sheets.  I also have macros set as token actions that call most of the character sheet buttons.  I want all the buttons (both token and character sheet) to work for both players and the gm. Some of the commands I would like to work from the character sheet even if there is no token selected, or even if there is no token for that character at all. For the gm, I would like some of the buttons to work on multiple selected tokens, even if different characters are selected. Ie: select 3 orks and a troll and hit Attack-1, and all each token rolls the correct attack for their represented character.  I have figured out how to tell if the user pressed a button on a character sheet, or pressed a token action. At present, my thinking is that the logic I want to follow is something like When called from a token action, perform the action for all selected tokens.  when called from a button on a character sheet that is a mook, perform for all selected tokens for that character. If none, error. when called from a button on a character sheet that is non-mook, FIND the token even if not selected. If there is no token on this page, see what can do with the character itself. This may cause called routines to error. So anyway, I am working on a general ForEach command that builds a list of tokens/chraacters that match the above rules. I have it working for the selected tokens, and am working on finding a character token on the correct page. I think I know how to do it so long as the GM has not moved to a page via the page toolbar. It sounds like you are saying there is no way to check for that, so I guess I will just have to make a note that it will not work if that is the case.  Any other comments would be appreciated. Thanks!
1448524118
The Aaron
Pro
API Scripter
Sounds like you have the right of it.  It would be grand if the GM moving to another page actually set him on that page.  Hopefully we can get that for the API soon.