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

TurnMarker1 Script - Help

Just came across this script and it is incredibly useful For various reasons I won't bore you with, in some games I need to login as a player (rather than remain a GM) for combat, and not being able to advance turns etc. was annoying - this script is a great solution. However the one missing element is being able to sort the turn order (so players are in initiative order). Does anyone know if there any way to add this to the script in some way?
1649393265
The Aaron
Roll20 Production Team
API Scripter
There are other scripts that can sort the turn order. I can throw one together for you tomorrow. 
Wow! Thank you, I wouldn't say no to that :-) That said... if you know of one in the library that does it (I tried doing a basic search) I'd be happy to do that to save you time.
As a side note... does the script use different functionality to switch turns than the right arrow on the turn order window (visible if you are the GM)? I ask as I notice that using EOT to switch turns isn't recognised by some other scripts that decrement counters when turns pass (e.g. Combat Master), while the right arrow is. Not a big deal, but was curious when I noticed this.
1649426103
The Aaron
Roll20 Production Team
API Scripter
Here's a sort script.  I set this up so players (you) can call it.  Use this command: !to-sort or if you want ascending: !to-sort --reverse Here's the code: on('ready',()=>{ const getTurnArray = () => ( '' === Campaign().get('turnorder') ? [] : JSON.parse(Campaign().get('turnorder'))); const packTo = (to) => [{id:'HEADER',pr:Number.MAX_SAFE_INTEGER},...to].reduce((m,t)=>{ if('-1'===t.id){ m[m.length-1].packed=[...(m[m.length-1].packed || []), t]; return m; } return [...m,t]; },[]); const unpackTo = (pTo) => pTo.reduce((m,t)=>{ let packed = t.packed||[]; delete t.packed; if('HEADER' === t.id){ return [...packed,...m]; } return [...m,t,...packed]; },[]); const sorter_asc = (a, b) => ('-1' === a.id || '-1' === b.id) ? 0 : a.pr - b.pr; const sorter_desc = (a, b) => ('-1' === a.id || '-1' === b.id) ? 0 : b.pr - a.pr; const sortTurnOrder = (sortBy = sorter_desc) => Campaign().set({turnorder: JSON.stringify(unpackTo(packTo(getTurnArray()).sort(sortBy)))}); /* eslint-enable no-unused-vars */ on('chat:message',msg=>{ if('api'===msg.type && /^!to-sort(\b\s|$)/i.test(msg.content) ){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let args = msg.content.split(/\s+--/).slice(1); let reverse = false; args.forEach(a=>{ let cmd = a.split(/\s+/); switch(cmd[0].toLowerCase()){ case 'reverse': reverse = true; break; } }); sortTurnOrder( reverse ? sorter_asc : sorter_desc ); sendChat('',`/w "${who}" <div>Turn Order sorted${reverse?' in reverse':''}.</div>`); } }); });
1649426325
The Aaron
Roll20 Production Team
API Scripter
Francesco said: As a side note... does the script use different functionality to switch turns than the right arrow on the turn order window (visible if you are the GM)? I ask as I notice that using EOT to switch turns isn't recognised by some other scripts that decrement counters when turns pass (e.g. Combat Master), while the right arrow is. Not a big deal, but was curious when I noticed this. Yes, the API Scripts must manually switch around the turn order.  !eot is implemented in TurnMarker1 and takes the first thing from the list of turns and puts it at the end.  !pot does the same thing in reverse.  Because those changes happen in script code, other scripts aren't aware of those changes unless they take special steps (for example, AddCustomTurn also listens for !eot so it can do it's updates if that command is issued).  There are ways to get all scripts to know when that even happens, but they require quite a bit of orchestration between the various script authors, and some generalized centralization of functionality, which is time consuming and difficult to write.  Often, if you hit on a common case (like !eot for CombatMaster), you can talk to the script author and they can find a way to support it.
Just tried the script works perfectly, thank you!
Hi, Aaron! Just recently switched from another tracker to this one, and it has impressed me quite a bit! I just had some additional questions, hoping to modify the code to better suit EXACLY what I am looking for, because I love how you laid out the code so much.  1.) Is there I way to set the token marker to set to the Map Layer? Whenever I set group conditions to player characters or npcs, the marker image gets the condition as well. This way, the marker can still be visible to the DM and the players, but not interfere with anything while setting multiple conditions at once (like with a box drag/select). 2.) Is there a way to have the players/enemies names appear in the chat when announcing turns? It just says current player's and previous player's turn, but not their names. I have their names set up and everything in their settings but nothing seems to change it, even though you code lines do account for the names being added... just trying to figure out why it isn't linking from the code. 3.) Instead of having the previous turn, and the current turn, how can I change the code, so it represents the current turn, and then the NEXT turn. Something like "it's now x's turn" and then "X character, you are up next!" Or possibly, all three?