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

Moving Player Ribbons Using Object.set(_pageid)

I've been working on a script to move tokens, and the players that control them, between different pages. I was unable to set the tokens _pageid as, according to the API website, that attribute is unalterable so my solution was to destroy the object and reinstantiate it on the destination page. However, I am now running into the issue of transferring the player who controls the token to the destination page. It seems like using Object.set("_pageid: "destination") is out of the question. Is there another solution I am missing? I appreciate any help.
1747687456
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
You use the campaign function  and set the playerpageid or playerspecificpages depending on if you want to move the ribbon or a specific player: Campaign().set({playerpageid:'id-of-page'}); // OR Campaign().set({playerspecificpages:'page-id-for-specific-player'}) If you want to ensure that all players are on the ribbon, you can set playerspecificpages to false.
Thank you! I just went through the GitHub for MapChange and found this! I am having a bit of trouble getting the players to come back to the initial screen, but I did get the jump to work!
1747688539
timmaugh
Forum Champion
API Scripter
Tokens only exist on the page where you create them. If you want the illusion of the token moving from this page to that, you just create a new, doppleganger token on the new/destination page. To move players, you will want to manage the "playerpageid" property on the Campaign object, as well as the " playerspecificpages" property. The former represents the ribbon; the latter represents anyone who was dragged away from the ribbon (or any GM that has changed pages). If everyone is on the ribbon, the playerspecificpages property will be "false", otherwise it will be an object keyed with playerIDs that each have a value of the pageID they are on. Changing those properties are what will move your players to new pages: set the playerspecificpages to false to move everyone to the ribbon, and/or set the playerpageid to move the ribbon, and/or assign the player a value on the playerspecificpages property object to move that player to a page away from the ribbon
1747688590
timmaugh
Forum Champion
API Scripter
Ninja'd. But that pizza I stopped to eat... wasssssssss... pretty good. Worth it. =D
1747690739
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Zak said: Thank you! I just went through the GitHub for MapChange and found this! I am having a bit of trouble getting the players to come back to the initial screen, but I did get the jump to work! I haven't worked with the page changing stuff in a while, but if I remember correctly from working on PageNavigator, there's a weird bug where you need to set player specific pages to false before then setting it to whatever specific object you want it to be (e.g. moving only one player back to the ribbon).