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

Question regarding getting Custom Tokens using Campaign().get("token_markers")

1599840049
Chuz
Pro
Sheet Author
API Scripter
Compendium Curator
I am trying to dynamically load the tokens in the campaign using Campaign().get("token_markers") however I'm coming up with the problem that the reference is undefined at the point that I need the token list.&nbsp;&nbsp; I am doing this within a custom API script (a modified Tracker Jacker).&nbsp;&nbsp; If I use the example code from here <a href="https://app.roll20.net/forum/post/8033593/release-note-for-january-7-2020" rel="nofollow">https://app.roll20.net/forum/post/8033593/release-note-for-january-7-2020</a> it works fine as a chat command !markernames.&nbsp; I am even able to modify it to output an object containing the markers.&nbsp; My problem arises when I try to reference that object later in the Tracker Jacker code with a no such reference error.&nbsp; If I pull the code to get the token markers out of the on("ready" block so it executes before the Tracker Jacker code then I get the error TypeError: Cannot read property 'get' of undefined If I'm understanding things correctly that means that Campaign().get isn't available until AFTER execution of all of the API scripts.&nbsp; If I'm correct about this, is there a way to get the markers earlier or do I have to find a way to do it on the fly every time I need the list?&nbsp; Forgive me if the answer is obvious, javascript isn't my native language. Thanks, Chuz
1599841544
The Aaron
Roll20 Production Team
API Scripter
You might find this useful:&nbsp; <a href="https://app.roll20.net/forum/post/8061179/script-library-libtokenmarkers-a-resource-for-scripts-which-simplifies-using-the-new-token-markers" rel="nofollow">https://app.roll20.net/forum/post/8061179/script-library-libtokenmarkers-a-resource-for-scripts-which-simplifies-using-the-new-token-markers</a> It should handle most, if not all, of the drudgery.
1599841922
GiGs
Pro
Sheet Author
API Scripter
You should post the code youre actually using. I've used the code from that page directly, and it worked fine. It'll be impossible to figure out what's up with your code without seeing it.
1599861566
Chuz
Pro
Sheet Author
API Scripter
Compendium Curator
Thanks for the responses, I found that I was putting a separate on("ready") block in.&nbsp; Once I shuffled things around a bit I now have access to the tokens.&nbsp; Now I'm fighting my way through Tracker Jacker dealing with issues caused by toLowerCase in some places but not others but that's a task I can handle.