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

[Script] AddCustomTurn -- An easy way to add (and remove) custom turns which increment or decrement, and have auto delete features.

1625445614
The Aaron
Roll20 Production Team
API Scripter
AddCustomTurn v0.1.1 AddCustomTurn provides an easy way to add (and remove) custom turns which increment or decrement, and have auto delete features. Commands !act [&lt;formula&gt; | [&lt;initial&gt;]] &lt;--&lt;custom turn name&gt;&gt; [--delete-on-zero | --delete-lt &lt;number&gt; | --delete-le &lt;number&gt; | --delete-eq &lt;number&gt; | --delete-ge &lt;number&gt; | --delete-gt &lt;number&gt; | --after | --index &lt;number&gt; | --help] Add a custom turn to the Turn Order, with options for adjusting it each turn, and removing it when it has a specified value. Positional Arguments &lt;formula&gt; &nbsp;-- The formula for changing the turn.&nbsp; + &nbsp;or&nbsp; - &nbsp;prepended to the number specify the direction. ( Default :&nbsp; +1 &nbsp;) &lt;initial&gt; &nbsp;-- The initial value for the custom turn. ( Default :&nbsp; 0 &nbsp;) Dash Arguments --&lt;custom turn name&gt; &nbsp;-- The name of the custom turn to add. --delete-on-zero &nbsp;-- deletes the custom turn when its value is less than or equal to 0. Shorthand for&nbsp; --delete-le 0 . --delete-lt &lt;number&gt; &nbsp;-- deletes the custom turn when its value is less than&nbsp; &lt;number&gt; . --delete-le &lt;number&gt; &nbsp;-- deletes the custom turn when its value is less than or equal to&nbsp; &lt;number&gt; . --delete-eq &lt;number&gt; &nbsp;-- deletes the custom turn when its value is equal to&nbsp; &lt;number&gt; . --delete-ge &lt;number&gt; &nbsp;-- deletes the custom turn when its value is greater than or equal to&nbsp; &lt;number&gt; . --delete-gt &lt;number&gt; &nbsp;-- deletes the custom turn when its value is greater than&nbsp; &lt;number&gt; . --after &nbsp;-- adds the custom turn after the current turn. Shorthand for&nbsp; --index 1 . --index &lt;number&gt; &nbsp;-- adds the custom turn after the entry at index&nbsp; &lt;number&gt; . --help &nbsp;-- Shows the Help screen. !dct [&lt;custom turn name&gt; | --help] Remove a custom turn from the turn order by name. When used by the GM, removes the first custom turn with the given name. When used by a player, removes the first custom turn they created with the given name. Positional Arguments &lt;custom turn name&gt; &nbsp;-- The name of the custom turn to remove. Dash Arguments --help &nbsp;-- Shows the Help screen. Examples Add a turn that just counts up. Custom turn names can contain spaces: !act --Counter for Rounds Add a turn that counts down from 10: !act -1 10 --Bless Add a turn that counts down from 10 and is after the first item in the turn order (All examples are the same): !act -1 10 --Bless --after !act -1 10 --Bless --index 1 !act -1 10 --after --Bless !act -1 10 --index 1 --Bless Add a turn that counts down from 10 and removes itself when it reaches 0 (All examples are the same): !act -1 10 --Bless [Bob the Slayer] --delete-on-zero !act -1 10 --Bless [Bob the Slayer] --delete-le 0 !act -1 10 --delete-on-zero --Bless [Bob the Slayer] !act -1 10 --delete-le 0 --Bless [Bob the Slayer] Supports multi-line syntax by wrapping with&nbsp; {{ &nbsp;and&nbsp; }} : !act&nbsp;-1&nbsp;10&nbsp;{{ &nbsp;&nbsp;--Bless&nbsp;[Bob&nbsp;the&nbsp;Slayer] &nbsp;&nbsp;--delete-on-zero &nbsp;&nbsp;--after }} Removing a turn named&nbsp; Bless : !dct Bless Removing a turn named&nbsp; Bless [Bob the Slayer] : !dct Bless [Bob the Slayer] Github link: <a href="https://github.com/shdwjk/Roll20API/blob/master/AddCustomTurn/AddCustomTurn.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/AddCustomTurn/AddCustomTurn.js</a> Available on the 1-click soon. Support my work on If you use my scripts, want to contribute, and have the spare bucks to do so , go right ahead. However, please don't feel like you must contribute just to use them! I'd much rather have happy Roll20 users armed with my scripts than people not using them out of some sense of shame. Use them and be happy, completely guilt-free! Disclaimer: This Patreon campaign is not affiliated with Roll20; as such, contributions are voluntary and Roll20 cannot provide support or refunds for contributions.
1625447627

Edited 1625447830
vÍnce
Pro
Sheet Author
1625451082
The Aaron
Roll20 Production Team
API Scripter
Fixed a minor bug with deleting the first entry (Thanks&nbsp; vÍnce&nbsp; )
This is a great update! I've been using your original !act script along with the !aict &nbsp;'hidden turn order' script. Are you planning on including the 'invisible' custom turn item in this script? It would be great if it could be included as another argument like '--hidden'. Thanks for all the incredible scripts you create!
1625491794
The Aaron
Roll20 Production Team
API Scripter
Indeed I am! &nbsp;This was just step one, the code is ready for me to add the invisible ones shortly. =D
This is great! Just added it and have it doing everything I hoped for.
1625499122
The Aaron
Roll20 Production Team
API Scripter
Great!
Awesome. Can duration be a formula such a @{selected|Level}*10 ? I've had issues with the orig !act command trying formulas for the starting count number.
1625533377
The Aaron
Roll20 Production Team
API Scripter
You can use formulas if you put them in an inline roll: !act -1 [[&nbsp; @{selected|Level}*10 ]] --Holding your breath
1625581743

Edited 1625582329
Apparently the inline roll trick doesn't work in powercards. Sigh. Neither does the delete on 0. The Aaron said: You can use formulas if you put them in an inline roll: !act -1 [[&nbsp; @{selected|Level}*10 ]] --Holding your breath
1625582625
The Aaron
Roll20 Production Team
API Scripter
I don't use powercards, but can you post the command you're trying to use and maybe we can figure out how to get it working for you?
--api_act|-1 [[ @{selected|Level}*10 ]] _delete-on-zero _Bless
Wow this is awesome. Thank you for posting this!&nbsp;
1625668263
The Aaron
Roll20 Production Team
API Scripter
AddCustomTurn is now in the 1-click installs!
Yep I used the one click to install it works great!&nbsp; I have a question? Is there a way to add an icon or change the tracker color for custom turn markers?
1625674325
The Aaron
Roll20 Production Team
API Scripter
Not yet, but there will be when I integrate AddCustomImageTurn into this.
Well I did figure out that you can do random or formulaic durations in powercards if you use it as a roll reference. !power {{ --roll|[[ [$Turn] 1d8 ]] --api_act|-1 [^Turn] _delete-on-zero _Bless }} But I still can't get delete-on-zero to work in powercards.
1625681816
The Aaron
Roll20 Production Team
API Scripter
Hmm.&nbsp; I just copy/pasted what you put above and it seems to have worked for me?
1625682161
The Aaron
Roll20 Production Team
API Scripter
Are you using the version in the 1-click?
I am. Maybe one of the other scripts is interfering. But at least I can have varied duration. The Aaron said: Are you using the version in the 1-click?
1625683720

Edited 1625683951
Just to clarify, the only part that doesn't seem to work for me is the delete on zero.
And now, like magic, it works. SMH. Peacekeeper B said: Just to clarify, the only part that doesn't seem to work for me is the delete on zero.
1625684720
The Aaron
Roll20 Production Team
API Scripter
What does your output from ACT look like?
1625684733
The Aaron
Roll20 Production Team
API Scripter
Oh, well great! =D
I know im not thew first one to ask (i saw someone on Nick Olivos channel ask the same thing on the ACT counter video) but is there any way to add the counter at the end of the turn tracker without manualy entering the number of elements in it?&nbsp; I always loved this piece of work of yours since the act counter but never was able to use it since puting the element at the front of the turn tracker messes up a lot of things for me since combat based&nbsp; api's like Combatmaster care about order and whats on top, have something new apear at the top messes up the counters on conditions, the turn highlighter image, etc. The --after function doesnt quite do it since most effects in DND end at the beggining of your turn after the X amount of rounds and since putting it at the top isnt usefull at least for me the very bottom is the best solution, in fact thats the way roll20 adds custom elements. I sorry to bother about such thing but I LOVE THIS SO MUCH and i really really want to use it. Also just out of curiosity is the whats the main purpose of the --after? like I understand it puts it after the current turn but why? is there any effect/spell that you had in mind when developing this? Thank you your the best Aaron!!!
1625763434

Edited 1625763458
The Aaron
Roll20 Production Team
API Scripter
Not explicitly, but if you do: !act -1 10 --Bless --index 10000 it will be at the end unless you're combats are really, REALLY complicated. In my own games, we used --after for players adding their own spell durations.&nbsp; We like to have them listed after the character that cast them, so we would always end up manually moving them.
1625763866

Edited 1625763942
The Aaron
Roll20 Production Team
API Scripter
The instructions say:&nbsp; --index &lt;number&gt; &nbsp;-- adds the custom turn after the entry at index But that's really a simplification.&nbsp; It's actually the index to insert the entry into, 0-biased. A 0 inserts it as the zeroth element of the turn order, which is first, a 1 inserts it as "oneth" element, or in the second slot.&nbsp; It's easier for most people to think of this as "after the first element".&nbsp; inserting it at the 10000th position just means all the intervening positions are ignored and it ends up as the last position, assuming you have fewer than 10,000 entries already. And really, that's actually a bit of a simplification, it's technically the position at which the turn order array is split, with one part put before the new entry and one part after, but that's just splitting hairs... =D
1625764049
The Aaron
Roll20 Production Team
API Scripter
Also, that's a great point on the "ends at the beginning of your turn", I should put some thought into the implications of that and some possible enhancements to AddCustomTurn...
Just saw this thread, looks great, thank you! Have you considered an option to post something to chat when an item expires, like “Bless on Bob has ended”? It would make effect endings more obvious vs. noticing that something is no longer in the turn order. Allowing customizing the ending message might be nice (including allowing API calls to TokenMod? ;-) ), but isn’t required.
1626883908
The Aaron
Roll20 Production Team
API Scripter
That's a great idea! &nbsp;I could pull in some logic from OnMyTurn to handle the commands. Hmmm...
1626916105
vÍnce
Pro
Sheet Author
Joe said: Just saw this thread, looks great, thank you! Have you considered an option to post something to chat when an item expires, like “Bless on Bob has ended”? It would make effect endings more obvious vs. noticing that something is no longer in the turn order. Allowing customizing the ending message might be nice (including allowing API calls to TokenMod? ;-) ), but isn’t required. Great idea.
Is there a way to remove a token marker when the turn expires ?&nbsp;
1630291389
The Aaron
Roll20 Production Team
API Scripter
You could do that with OnMyTurn and TokeMod, I believe.&nbsp;
1631070876
Pktome
Pro
Sheet Author
If you put a COUNTER to start with -1 and for each next turn remove -1 (-1,-2,-3,-4,...) AND if there is ANOTHER COUNTER to be removed when reaching a value (ex. : starts with 6 and ends with 0) that is just before TurnOrder, after being removed (ANOTHER COUNTER) it ignores the effect of removing -1.
1631071080
Pktome
Pro
Sheet Author
Imagine the situation: Combat starts, we are in Turn 1 (in the image would be -1). On the PERSONA turn he will use a Spell that will go into Cooldown with 6 Turns. (Note that I need to put it to start with 7 because as soon as it hits the Counter, it already removes 1.)
1631071267
Pktome
Pro
Sheet Author
This is the beginning of the second turn (-2), after passing PERSONA's Turn and the Spell COUNTER, the Turns will be counted (starts with 6 and goes to 0). In my System, the cooldown of spells doesn't count the "own turn it was used". So the next turn PERSONA could use this same spell would be turn 8 (-8)
1631071469
Pktome
Pro
Sheet Author
It works perfectly for this purpose, but when it reaches Turn 7 (-7), the ideal would be that when it arrives at CD-Magia One it removes 1 and for reaching 0, it is removed.
1631071589
Pktome
Pro
Sheet Author
And he removes the CD-Magic One, but because it's right before the Turn Counter (-7) he FORCES the Turn Counter to be next on the Turn Order, but doesn't make the -1 so it becomes -8. Is this a bug or is it supposed to work like this? In the next image I "passed" the turn but it had no effect (-1, make -7 into -8)
1631077023
The Aaron
Roll20 Production Team
API Scripter
This is a bug. What's happening is the removal of the entry is not being interpreted as a turn change. It should be an easy fix, I'll take a look.&nbsp;
1631092760
Sr. K
Pro
Sheet Author
Pktome said: And he removes the CD-Magic One, but because it's right before the Turn Counter (-7) he FORCES the Turn Counter to be next on the Turn Order, but doesn't make the -1 so it becomes -8. Is this a bug or is it supposed to work like this? In the next image I "passed" the turn but it had no effect (-1, make -7 into -8) You can create a new turn: Fin de turno (0) as a work arround to keep the turn change on the counter, I guess.
1631129905
Pktome
Pro
Sheet Author
I think I can solve the problem, but my fear is that there will be so many small adjustments that it becomes impossible to read TurnOrder because I have so much information. In my system a single character can have multiple effects or cast multiple spells that have their own duration and cooldown. I created the post to see if it is not a bug type, because if there is another counter other than the "Contador de Turno", any marker that is deleted when reaching zero will prevent the next one (if any) from making the calculations.
Pktome said: I think I can solve the problem, but my fear is that there will be so many small adjustments that it becomes impossible to read TurnOrder because I have so much information. You may want to look into using the&nbsp; Stylus browser extension to adjust the Turn Tracker and make it smaller . I find it helps when there are a lot of items on the tracker.
is there a way i can use this to automate the Shadowrun 2 inititive system? basically i need something that adds someone to the initiative several times at increments of -10 of their original roll but where it doesn't go below 0. so if they got 23 they'd be added at 13 and 3 as well. At first i thought using this but with the increment being lowered by 10 after the players turn then you'd just have to resort the turn order but the issue with that is they need to stay in at their higher roll as well for following rounds. the ideal is that a roll query asks them what their initiative roll was then adds their name to the turn order with maybe a #1, #2 etc after for each increment. any ideas how i could do this?
1634153095
The Aaron
Roll20 Production Team
API Scripter
I think I've written something for that in the past, I'll see if I can find it.
1634153388
The Aaron
Roll20 Production Team
API Scripter
Look at SR-NextPass in the One-Click API Scripts.&nbsp; The GM runs it at the end of a round (but you could add an OnMyTurn character to run it for you once per round), and it deducts 10 from each entry's turn, removing those that fall to 0 or below.&nbsp; When the turn order is empty, you roll everyone in again.
1639152903

Edited 1639153756
The Aaron said: Look at SR-NextPass in the One-Click API Scripts.&nbsp; The GM runs it at the end of a round (but you could add an OnMyTurn character to run it for you once per round), and it deducts 10 from each entry's turn, removing those that fall to 0 or below.&nbsp; When the turn order is empty, you roll everyone in again. thanks man only just saw this as forgot to follow this topic after posting my question. this almost does what i want but in our game we don't reroll initiative after all turns done we use the same so we need a system where each person is added several times at each 10 count, thsi is what i've put together so far: For tokens with character sheets: &amp;{template:default} {{name=@{selected|token_name}'s Initiative}}{{Result=[[[@{selected|initiative|max}d6+@{selected|reaction|max}&amp;{tracker}]]](!act 0 [[@{tracker|@{selected|token_name}}-10]] --@{selected|token_name} --delete-on-zero --after !act 0 [[@{tracker|@{selected|token_name}}-20]] --@{selected|token_name} --delete-on-zero --after !act 0 [[@{tracker|@{selected|token_name}}-30]] --@{selected|token_name} --delete-on-zero --after)}} For tokens without character sheets: !act 0 ?{initiative?} --?{Name?} --delete-on-zero !act 0 [[?{initiative?}-10]] --?{Name?} --delete-on-zero --after !act 0 [[?{initiative?}-20]] --?{Name?} --delete-on-zero --after !act 0 [[?{initiative?}-30]] --?{Name?} --delete-on-zero --after these work but they leave loads of minus value initiative items and the player has to activate the chat menu item to add the extra turns, the minus values get deleted eventually but i'd love to be able to automate the whole thing more and lose the minus values altogether. Either this or if there was a way to use SR-nextpass but where it saved the turnorder at the beginning and then when next pass had run to the point of no turns being left it reloaded back to the starting turnorder
1639157399
The Aaron
Roll20 Production Team
API Scripter
Ok, so what you really need is something that lets you expand all turns out to all their possible turns between what they rolled and each value that is a multiple of 10 lower, but not below zero.&nbsp; So the workflow might be: Clear initiative All players and foes roll into initiative Initiatives are expanded to all turns below roll. Play the encounter Is that about right?
The Aaron said: Ok, so what you really need is something that lets you expand all turns out to all their possible turns between what they rolled and each value that is a multiple of 10 lower, but not below zero.&nbsp; So the workflow might be: Clear initiative All players and foes roll into initiative Initiatives are expanded to all turns below roll. Play the encounter Is that about right? Sounds spot on!
1639310526
Andrew R.
Pro
Sheet Author
I just used this to solve a complex Initiative roll in my 13th Age Glorantha campaign. Huzzah!&nbsp; <a href="https://app.roll20.net/forum/permalink/10547465/" rel="nofollow">https://app.roll20.net/forum/permalink/10547465/</a>
The Aaron said: Ok, so what you really need is something that lets you expand all turns out to all their possible turns between what they rolled and each value that is a multiple of 10 lower, but not below zero.&nbsp; So the workflow might be: Clear initiative All players and foes roll into initiative Initiatives are expanded to all turns below roll. Play the encounter Is that about right? Is this something you can help with?
1640269079
The Aaron
Roll20 Production Team
API Scripter
lark86 said: Is this something you can help with? Yes, I believe I have a script somewhere that can do this, I just need to find it.&nbsp;