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.

July 05 (3 years ago)
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 [<formula> | [<initial>]] <--<custom turn name>> [--delete-on-zero | --delete-lt <number> | --delete-le <number> | --delete-eq <number> | --delete-ge <number> | --delete-gt <number> | --after | --index <number> | --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
  • <formula> -- The formula for changing the turn. + or - prepended to the number specify the direction. (Default+1 )
  • <initial> -- The initial value for the custom turn. (Default0 )
Dash Arguments
  • --<custom turn name> -- The name of the custom turn to add.
  • --delete-on-zero -- deletes the custom turn when its value is less than or equal to 0. Shorthand for --delete-le 0.
  • --delete-lt <number> -- deletes the custom turn when its value is less than <number>.
  • --delete-le <number> -- deletes the custom turn when its value is less than or equal to <number>.
  • --delete-eq <number> -- deletes the custom turn when its value is equal to <number>.
  • --delete-ge <number> -- deletes the custom turn when its value is greater than or equal to <number>.
  • --delete-gt <number> -- deletes the custom turn when its value is greater than <number>.
  • --after -- adds the custom turn after the current turn. Shorthand for --index 1.
  • --index <number> -- adds the custom turn after the entry at index <number>.
  • --help -- Shows the Help screen.

!dct [<custom turn name> | --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
  • <custom turn name> -- The name of the custom turn to remove.
Dash Arguments
  • --help -- 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 {{ and }}:

!act -1 10 {{
  --Bless [Bob the Slayer]
  --delete-on-zero
  --after
}}

Removing a turn named Bless:

!dct Bless

Removing a turn named Bless [Bob the Slayer]:

!dct Bless [Bob the Slayer]


Github link: https://github.com/shdwjk/Roll20API/blob/master/AddCustomTurn/AddCustomTurn.js

Available on the 1-click soon.


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.
July 05 (3 years ago)

Edited July 05 (3 years ago)
vÍnce
Pro
Sheet Author



July 05 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Fixed a minor bug with deleting the first entry (Thanks vÍnce )

July 05 (3 years ago)

This is a great update! I've been using your original !act script along with the !aict '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!

July 05 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Indeed I am!  This was just step one, the code is ready for me to add the invisible ones shortly. =D

July 05 (3 years ago)

This is great! Just added it and have it doing everything I hoped for.

July 05 (3 years ago)
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.

July 06 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

You can use formulas if you put them in an inline roll:

!act -1 [[ @{selected|Level}*10 ]] --Holding your breath
July 06 (3 years ago)

Edited July 06 (3 years ago)

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 [[ @{selected|Level}*10 ]] --Holding your breath





July 06 (3 years ago)
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! 

July 07 (3 years ago)
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!  I have a question? Is there a way to add an icon or change the tracker color for custom turn markers?

July 07 (3 years ago)
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.

July 07 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Hmm.  I just copy/pasted what you put above and it seems to have worked for me?



July 07 (3 years ago)
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?




July 07 (3 years ago)

Edited July 07 (3 years ago)

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.




July 07 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

What does your output from ACT look like?

July 07 (3 years ago)
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? 

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  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!!!

July 08 (3 years ago)

Edited July 08 (3 years ago)
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.  We like to have them listed after the character that cast them, so we would always end up manually moving them.

July 08 (3 years ago)

Edited July 08 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

The instructions say: 

--index <number> -- adds the custom turn after the entry at index

But that's really a simplification.  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.  It's easier for most people to think of this as "after the first element".  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

July 08 (3 years ago)
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...

July 21 (3 years ago)
Joe
Pro

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.

July 21 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

That's a great idea!  I could pull in some logic from OnMyTurn to handle the commands. Hmmm...

July 22 (3 years ago)
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 ? 

August 30 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

You could do that with OnMyTurn and TokeMod, I believe. 

September 08 (3 years ago)
Pktome
Pro
Marketplace Creator
Sheet Author
Compendium Curator

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.

September 08 (3 years ago)
Pktome
Pro
Marketplace Creator
Sheet Author
Compendium Curator

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


September 08 (3 years ago)
Pktome
Pro
Marketplace Creator
Sheet Author
Compendium Curator

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)

September 08 (3 years ago)
Pktome
Pro
Marketplace Creator
Sheet Author
Compendium Curator

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.

September 08 (3 years ago)
Pktome
Pro
Marketplace Creator
Sheet Author
Compendium Curator

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)

September 08 (3 years ago)
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. 

September 08 (3 years ago)
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.

September 08 (3 years ago)
Pktome
Pro
Marketplace Creator
Sheet Author
Compendium Curator

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.

September 08 (3 years ago)

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

October 13 (3 years ago)

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?

October 13 (3 years ago)
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.

October 13 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Look at SR-NextPass in the One-Click API Scripts.  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.  When the turn order is empty, you roll everyone in again.

December 10 (3 years ago)

Edited December 10 (3 years ago)


The Aaron said:

Look at SR-NextPass in the One-Click API Scripts.  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.  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:

&{template:default} {{name=@{selected|token_name}'s Initiative}}{{Result=[[[@{selected|initiative|max}d6+@{selected|reaction|max}&{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

December 10 (3 years ago)
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.  So the workflow might be:

  1. Clear initiative
  2. All players and foes roll into initiative
  3. Initiatives are expanded to all turns below roll.
  4. Play the encounter

Is that about right?


December 12 (3 years ago)


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.  So the workflow might be:

  1. Clear initiative
  2. All players and foes roll into initiative
  3. Initiatives are expanded to all turns below roll.
  4. Play the encounter

Is that about right?


Sounds spot on!


December 12 (3 years ago)
Andrew R.
Pro
Sheet Author

I just used this to solve a complex Initiative roll in my 13th Age Glorantha campaign. Huzzah! 

https://app.roll20.net/forum/permalink/10547465/

December 22 (3 years ago)


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.  So the workflow might be:

  1. Clear initiative
  2. All players and foes roll into initiative
  3. Initiatives are expanded to all turns below roll.
  4. Play the encounter

Is that about right?



Is this something you can help with?

December 23 (3 years ago)
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.