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

Two more questions! pageid + controlledby

Very close to being done with the script I wanted to write now I just need to figure out how to get a reference to the GM for the controlledBy reference within createObj and a way to get the pageid the GM is currently viewing yet again for the createObj ref. thanks again! and thanks to everyone who has helped me so far. I do plan on sharing this script which will take TSV files generated by&nbsp; <a href="https://donjon.bin.sh/pathfinder/dungeon/" rel="nofollow">https://donjon.bin.sh/pathfinder/dungeon/</a> and make them into a map with lighting and custom random ground tiles!
1488132666

Edited 1488132740
Lithl
Pro
Sheet Author
API Scripter
There is no way to tell what page the GM is looking at. You can get the page that currently has the player ribbon (the page a player will be on if they haven't been split from the party), and the page that individual players who have been split from the party are on, but the GM can look at any page regardless of that. You shouldn't need to specify the GM's is for the controlledby field of any object created; users with GM permissions can control any object on the VTT, including objects with no &nbsp;controlledby value. However, you could get a list of GMs by filtering the players: const gms = _.filter(findObjs({type: 'player'}), (p) =&gt; playerIsGM(p.id)); If you simply must have all of their ids in the same format as used by controlledby, you could map the list like so: const gmids = _.map(gms, (g) =&gt; g.id).join(',');
1488132696

Edited 1488132721
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
There's no way to tell directly what page the gm is viewing. A workaround that has been used both others is to have the gm move the player flag or themselves to a page via dag and drop of their avatar. For the controlled by reference, do you just want the generated object to be co trollable by the GM? No special entry in controlled by is required for this as the gm has control of everything in the game. ninjad by Brian :)
1488134310
The Aaron
Pro
API Scripter
Actually.. =D Let me draw your attention to the _lastpage property of the player object: &nbsp; <a href="https://wiki.roll20.net/API:Objects#Player" rel="nofollow">https://wiki.roll20.net/API:Objects#Player</a> This is filled in with the last page that at player loaded as a GM. &nbsp;For practical purposes, it's the page the GM is looking at. &nbsp;The only exception is when the GM is connected with multiple browsers.
1488136195
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
huh, I could of sworn I had tried using that before, but it didn't update in real time.