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 .
×
Advertisement Create a free account

Special init API (new to API part of roll20)

1638351506
Hey, So Im fairly new to the API part of roll20, so some of these questions might be pretty basic so if someone could just point me in the right direction that would be a great help! So in our game we are doing hidden init, so we cant power game combat too much. But that comes with the drawback that our GM have to have a list outside of roll20 with all players, NPC and monster with init and keep track of it (we are playing shadowrun). So i want to make an API that helps him. My plan is to make a GM part in our character sheet with a repeating fieldset with players, NPCs and monsters (know how to make the character sheet). What I want is then to have an API that checks the chat and every time there is an init roll takes the value of the roll and adds it to the row with the corresponding name.  Is this possible, or am i dreaming to big?
1638352373
GiGs
Pro
Sheet Author
API Scripter
What you're asking for can be done, if you are building the results inside Roll20. I'm a little consided about this bit: Niels B. said: But that comes with the drawback that our GM have to have a list outside of roll20 with all players, NPC and monster with init and keep track of it (we are playing shadowrun). So i want to make an API that helps him. Roll20 scripts can only generate values inside roll20. You cant export outside (well, there are some ways to do it with the external journal, but you'd likely need to build a browser extension to make use of that). Probably the way I'd recommend is to have your API script send the initiative data to a handout, which only the GM has permission to view. That way the GM can view the data for all characters in one place. You could have a script for rolling initiative that rolls intiative as normal, and updates the handout at the same time. That said, is there a reason the normal initiative tracker doesnt serve the GMs purpose? Any NPCs and monsters still on the GM layer aren't visible to players, so their initiative totals remain hidden.
1638355270
Andrew R.
Pro
Sheet Author
I suggest using Tokens on the GM Layer in the Turn Tracker. These will be visible to the GM only. No special API is needed for this. The GroupInit script may make things faster for the GM. 
1638356351
My bad, wasnt very clear. The way he is doing it now is having a list outside roll20, but i want to have it inside now. The reason why I wanted to do it in a repeating fieldset is because we are playing shadowrun so the init changes if you take damage or makes certain actions. So my GM can sort the list when needed. GiGs  said: That said, is there a reason the normal initiative tracker doesnt serve the GMs purpose? Any NPCs and monsters still on the GM layer aren't visible to players, so their initiative totals remain hidden. Because as a player I dont even know the init of the other players or monsters Im fighting. I know its a little wierd, but its so the players can make urealistik plans based on the init of others.  But ist possible to have an API look through the rows of a repeating fieldset, find the row with a matching name. And then add the value of the roll to an attribute on that row? :)
1638368426
timmaugh
Pro
API Scripter
Personally, I meta-theater my awareness of initiative tracker to my character's sense that this character seems to be moving well, and that NPC is really lumbering, but THAT NPC is moving like lightning. I figure it's not like we're all standing around, perfectly stock still, eyes darting from character to NPC to character to NPC until -- without warning -- one strikes out like film sped up to 100x speed, and then immediately returns to lock-straight, eyes darting. =D But, to each their own! Here is some info... First, to expand on Andrew's suggestion, tokens on the GM Layer do NOT show to the players even if the GM opens the Turn Tracker. That means you could have a representative token for each combat-involved character or NPC, and run/enter their initiative from these tokens. That might be a bit of overhead to figure out, but it would give the GM a graphical interface for examining the various initiatives. You could work out a system where the characters stored their initiatives in a particular place on the character sheet so the GM could run a process for collecting them (and run it any time something changed -- like someone taking damage) and then assigning them to the representative token. Second, roll collection... I don't think there's an easy way to grab an init roll by default. Init rolls, as generated by sheets, include the &{tracker} syntax token, but that is parsed out by the time the roll would reach the API. Here is an example init roll (original roll equation: [[1d20 &{tracker}]] ), with nothing that tells you that's what it was supposed to be: [ { expression: 1d20 , results: { resultType: sum , rolls: [ { dice: 1 , results: [ { v: 5 } ], rollid: -Mpq6o4hUejJyLmNxMvT , sides: 20 , type: R } ], total: 5 , type: V }, rollid: -Mpq6o4hUejJyLmNxMvT , tdseed: 8558542538790749000 } ] Besides, if you let people roll this way, their values will show up in the Turn Tracker to be visible to everyone if the GM turns it on. So if you were going to "listen" for initiative rolls, you'd probably do better to duplicate the initiative roll equation in an ability on the character sheet which would run your API: !backtrack [[1d20]] Then you might want to offer arguments that allow for wholesale rerolling an initiative, or incrementing it by +/- some amount, or just setting it to a given value. You might even want a way to designate who the roll is for so that the GM could roll for a character if necessary. If there was no "for token" argument in the command line, the script could assign the initiative to the selected token. If you built it this way, the GM could make use of the forselected handle of the SelectManager metascript to grab a series of tokens and run your API for them individually... rolling a unique initiative for a series of NPC tokens, or grabbing character tokens within some radius of an effect (because their initiatives were negatively affected by different amounts from what happened), and running a modification to each: !forselected(`) backtrack --decrement|[`[`1d4`]`] Last, as for storing this as a repeating item, here is a post on creating a row ID , and here is a post on accessing repeating items , if that's what you really want to do. I would hesitate to go that way, just because I'm envisioning that every sub-attribute of the repeating section would be for a new character or NPC... is that right? So you'd have: repeating_backtracker_-M1234567890abcdef_Blovia_the_Windbaggish = 5 repeating_backtracker_-M1234567890abcdef_Volcano_Man = 10 repeating_backtracker_-M1234567890abcdef_Actual_Cannibal_Shia_LaBeouf  = 12 The GM's interface for this would be the character sheet... which I'd find a bit cumbersome. Instead, I'd build it to track in the state object, and I'd build into the script a way for the GM to get a whisper of the turn order. The output could have easy/common adjustment buttons for each row, and a way to increment the turn order (and reproduce the chat menu) at the bottom: CHARACTER NAME | INIT | ACTIONS ------------------------------|--------|---------------------------------------------------------- Blovia the Windbaggish | 5 | [Remove] [-1] [+1] [+/- Custom] [Enter Value] [ReRoll] Volcano Man | 10 | [Remove] [-1] [+1] [+/- Custom] [Enter Value] [ReRoll] Actual Cannibal Shia LaBeouf | 12 | [Remove] [-1] [+1] [+/- Custom] [Enter Value] [ReRoll] -------------------------------------------------------------------------------------------------- [Advance Turn] [Previous Turn] [Sort Ascending] [Sort Descending] The GM would need actionable syntax for... ...starting new combat / clearing old combat ...displaying the current turn order and position ...sending a message to the character (or all characters, or selected tokens) to report information regarding their current initiative ...configuration options (sort order, message prompt to player who's turn it became, etc.) That process could be really slick. I might write that, if you don't. =D