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

Determining if a Map is Loaded for a Player

Is there a way to determine if a map has finished rendering for a player? I am using the Map Teleport API Script and the sendPing is happening before the map is rendered.  The effect is that the ping does not move the player's view to their token. I am using a setTimeout, but know that this is HIGHLY dependent on the user's browser speed.  I don't want players to have their map render in 0.5 sec and then 4.5 sec later ping, nor do I want a player to have their map render after the ping. Ideally, I would be able to use a promise or event to trigger the sendPing command.
1653958456
Oosh
Sheet Author
API Scripter
I can't think of anything apart from Player action that could reliably do this. I think you'd need to either snoop on the user's ajax responses (see when mapname.png finishes fetching) or hook into Canvas. Both of those need to be running in the user's browser, and written as extensions. I had a quick go at a Promisified requestAnimationFrame(), but there's too much non-graphics stuff loading, and it fires too early. I think it's only good for finding the end of a big texture load, and it's a bit hard to know when it starts... then the Canvas doesn't seem to paint until some time after the texture is available anyway. Unless there's an undocumented Player event sent to the sandbox, I think tweaking the setTimeout, or using setInterval to send multiple pings, is the best you can do. I can't think of any way to get an Ack from the player that they've received a ping, beyond the obvious like manually sending a chat message. Depending on how the script generates the ping coordinates, maybe you can give players a "center new map" macro that requests the ping, instead of broadcasting it? I'm not familiar with it.
1654059245
Victor B.
Pro
Sheet Author
API Scripter
No. Settimeout is the only way and you have to play with it.  Performance varies.  No one stop shopping for a setting.  Lean towards the slower side and have your party wait for it to kick off.  No other way
Oosh said: maybe you can give players a "center new map" macro that requests the ping, instead of broadcasting it? I'm not familiar with it. That's what I was thinking. This would also be useful for times I'm not using the teleport script, like when a player first loads the campaign. That would be me up for a very short timeout when I do use teleport.
Victor B. said: No. Settimeout is the only way and you have to play with it.  Performance varies.  No one stop shopping for a setting.  Lean towards the slower side and have your party wait for it to kick off.  No other way Thanks. I figured it was a list cause, but figured I'd ask.
1654498973

Edited 1654524829
Victor B.
Pro
Sheet Author
API Scripter
Basically you can't switch maps.  Roll20 architecture is too lame to support it.  Isn't tracking what is needed for APIs or even Rol20 itself to track.  They won't fix this unless 200 DMs come together and request it.  Probably not going to happen. 
1654513689

Edited 1654513780
Oosh
Sheet Author
API Scripter
Firebase is lame? Someone should let Google know. In all seriousness though, which bit isn't working? What isn't being tracked? edit - if you missed it, the point of the thread isn't "you can't change maps", it's a little deeper than that: "can you get an ACK from a player that they've finished rendering the page and are ready for an API script to send them some data"