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 .
×

Selecting all tokens and adding them to the turn order.

I am trying to write a very basic script that does three things in the following order: 1. Open up the turn order. 2. Selects all tokens in the exact same way that a human would type ctrl+A 3. Adds all tokens to the turn order without rolling anything, in the exact same way that a human could take ctrl+u The issue is that I am new to API scripts and macros and I am not sure what can and cannot be done. Any advice would be appreciated.
1672434122
timmaugh
Forum Champion
API Scripter
What is your level of coding experience? (Not gate-keeping, just don't want to aim beneath what you already know, or assume you know something that you don't.) Also, to be clear, scripts are written in JavaScript... Macros are the command-line text that get sent to Roll20 -- either to the chat or to the Script Moderator. Are you wanting to do this in a script (eg, JavaScript)?
I have experiance in coding academic software languages such as MatLab and Fortran, but little to no experiance in any useful coding languages. Given that I am trying to replicate key presses, I would assume that I am looking to write a script. Thank you for helping BTW.
If you have access to the API, you can also use ScriptCards to do what you need to without having to code in JS. Here is one I use for my Starfinder game. You select a token on the page, open the turn order window and run the macro. You do have to open that turn order window manually though. It will gather any token that is assigned as a character in any layer, add it to the turn order, then outputs rolls into chat for player to see and whispers npcs to the GM. You may have to change the conditional that is  ?[*S:sheet_type] -eq npc  for how your game's character sheets differentiates between pcs and npcs. You may also have to change the initiative attribute as well depending on the game.  !scriptcard {{ --#emoteState|Hidden --~PageTokens|array;pagetokens;Characters;@{selected|token_id};char --~CurrentCharacter|array;getfirst;Characters --#title|Rolling Inititive --:InititiveLoop| --#sourceToken|[&CurrentCharacter] --=CharInitiative|1d20 [Base] + [*S:initiative] [Initiative] --?[*S:sheet_type] -eq npc|*[img width=32 height=32][*S:t-imgsrc][/img]  [*S:character_name]; rolls a [$CharInitiative] for initiative.[br][br]|+[img width=32 height=32][*S:t-imgsrc][/img]  [*S:t-name]; rolls a [$CharInitiative.Text] = [b][$CharInitiative][/b] for initiative.[br][br] --~|turnorder;replacetoken;[&CurrentCharacter];[$CharInitiative] --~CurrentCharacter|array;getnext;Characters --?[&CurrentCharacter] -eq ArrayError|InititiveDone|InititiveLoop --:InititiveDone| --~|turnorder;sort }}