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

Was the turn tracker API changed a few months ago?

I had a custom API script to summon a token and as an option, add that token to the turn order at the current position. The turn tracker part just stopped working, and I'm not sure exactly when. Is there another way of tying a token to the tracker through the API? Here's the relevant code: if (rounds) {                                                               // This still correctly gets the correct # of rounds if (Campaign().get("turnorder") == "") {                    // This part also continues to work correctly turnorder = []; } else { turnorder = JSON.parse(Campaign().get("turnorder")); } turnorder.push({ id: newTok.id,                                  // Seems to get the correct id, pr: rounds,                                     //    and rounds formula: "-1"                                        //    sets the counter to down by 1 }); Campaign().set("turnorder", JSON.stringify(turnorder));     // Nothing goes into the } The other method of placing a marker into the tracker (not tied to a token) still seems to work fine:             if (rounds === undefined) rounds = 10; if (Campaign().get("turnorder") == "") { turnorder = []; } else { turnorder = JSON.parse(Campaign().get("turnorder")); } turnorder.push({ id: "-1", pr: rounds, custom: effect, formula: "-1" }); Campaign().set("turnorder", JSON.stringify(turnorder));
Ok, I found the 2/8 post on the change, but simply adding "_pageid" to the JASON string didn't do it. What am I missing? if (rounds) { if (Campaign().get("turnorder") == "") { turnorder = []; } else { turnorder = JSON.parse(Campaign().get("turnorder")); } turnorder.push({ pageid: newTok.pageid, id: newTok.id, pr: rounds, formula: "-1" }); Campaign().set("turnorder", JSON.stringify(turnorder)); }
1654514778
David M.
Pro
API Scripter
Try using a get function to retrieve pageid: newTok.get("_pageid") From the API Objects wiki page, "id" can be retrieved without using get, but other object properties will need to use the get syntax: <snip> Note:  The  id  property of an object is a globally-unique ID: no two objects should have the same one, even across different types of objects. In addition, since an object's id is frequently-accessed and never changes, there is a shortcut available where you can access it by using  obj.id  instead of  obj.get("_id")  if you wish (either will work). <snip>
Thanks David, turns out that obj.id doesn't work in this case, but it does work with the "get" method. I also needed to change the JSON parameter to "_pageid" turnorder.push({ _pageid: newTok.get("_pageid"), id: newTok.id, pr: rounds, formula: "-1" }); Thanks again for the help, Kevin