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
This post has been closed. You can still view previous posts, but you can't post any new replies.

Multiple initiatives added to tracker

Hey, so I am running a Final Fantasy 4th edition game and am using my own custom character sheet because roll20 doesnt have one yet. So how the games Initiative works is that they roll 3d10 and each face value is what phases they act in within the round. Is there a way i can code a button on the character sheet to roll and add them onto the tracker 3 seperate times? Instead of the &tracker overriding the previous roll?
The turn tracker requires a token ID for the character, and each change to the tracker requires this token ID as well (except for the custom entries, which require manual entry or API intervention). I'm not sure if it is going to be possible to have 3 entries in the tracker tied to the same token ID. Maybe if there were three separate  tokens for the same character on the same page, but I doubt that is the direction you want to go.
<a href="https://app.roll20.net/forum/post/6817409/multiple-initiative-values-for-a-single-character" rel="nofollow">https://app.roll20.net/forum/post/6817409/multiple-initiative-values-for-a-single-character</a> This has something similar that works, but it uses a system where it just reduces the initial value by 20. I was hoping i could get someone smarter than me to figure out how to alter this to fit my games system. Lol
1539639684
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I don't think a macro can add a custom turn item, either. I think that requires the API. Also, a macro won't be able to "remember" a previous roll for the purposes of eliminating duplicates.
1539645536
The Aaron
Pro
API Scripter
This is only possible with the API. I can help with that. Do you need to add anything to the rolls?
1539655270
The Aaron
Pro
API Scripter
Give this a try: Command is: !ff4init You can pass it inline rolls (or numbers) and it will add add turns for those rolls: !ff4init [[1d10]] [[1d10]] [[1d10]] Will add 3 turns for each selected token with the 3 values rolled. (probably makes sense to only select on token) You can pass 4 flags also: --clear :: This will clear out all the turns for the selected tokens before adding any rolls.&nbsp; So to reroll for a token, you can use: !ff4init --clear [[1d10]] [[1d10]] [[1d10]] --clear-all :: Only the GM can use this command, it will clear the initiative completely.&nbsp; Usually you'd want to use it alone: !ff4init --clear-all --sort-asc :: this will sort the turnorder in ascending order after adding the rolls.&nbsp; Only the GM can use this command: !ff4init --clear --sort-asc [[1d10]] [[1d10]] [[1d10]] --sort-desc :: this will sort the turnorder in descending order after adding the rolls.&nbsp; Only the GM can use this command: !ff4init --clear --sort-desc [[1d10]] [[1d10]] [[1d10]] The order of those flags doesn't matter: !ff4init [[1d10]] --sort-asc [[1d10]] [[1d10]] --clear Any arguments that are not from among the 4 supported flags will be converted to numbers (or 0) and used for the turn order. Let me know if you need any changes. =D Code: on('ready',()=&gt;{ const playerCanControl = (obj, playerid='any') =&gt; { const playerInControlledByList = (list, playerid) =&gt; playerIsGM(playerid) || list.includes('all') || list.includes(playerid) || ('any'===playerid &amp;&amp; list.length); let players = obj.get('controlledby') .split(/,/) .filter(s=&gt;s.length); if(playerInControlledByList(players,playerid)){ return true; } if('' !== obj.get('represents') ) { players = (getObj('character',obj.get('represents')) || {get: function(){return '';} } ) .get('controlledby').split(/,/) .filter(s=&gt;s.length); return playerInControlledByList(players,playerid); } return false; }; const getTurnArray = () =&gt; ( '' === Campaign().get('turnorder') ? [] : JSON.parse(Campaign().get('turnorder'))); const addTokenTurn = (id, pr) =&gt; Campaign().set({ turnorder: JSON.stringify( [...getTurnArray(), {id,pr}]) }); const removeTokenTurn = (tid) =&gt; Campaign().set({ turnorder: JSON.stringify( getTurnArray().filter( (to) =&gt; to.id !== tid)) }); const clearTurnOrder = () =&gt; Campaign().set({turnorder:'[]'}); const sorter_asc = (a, b) =&gt; a.pr - b.pr; const sorter_desc = (a, b) =&gt; b.pr - a.pr; const sortTurnOrder = (sortBy = sorter_desc) =&gt; Campaign().set({turnorder: JSON.stringify(getTurnArray().sort(sortBy))}); const processInlinerolls = (msg) =&gt; { if(_.has(msg,'inlinerolls')){ return _.chain(msg.inlinerolls) .reduce(function(m,v,k){ let ti=_.reduce(v.results.rolls,function(m2,v2){ if(_.has(v2,'table')){ m2.push(_.reduce(v2.results,function(m3,v3){ m3.push(v3.tableItem.name); return m3; },[]).join(', ')); } return m2; },[]).join(', '); m['$[['+k+']]']= (ti.length &amp;&amp; ti) || v.results.total || 0; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },msg.content) .value(); } else { return msg.content; } }; on('chat:message', (msg)=&gt;{ if('api'===msg.type &amp;&amp; /^!ff4init\b/i.test(msg.content)){ let cmds = processInlinerolls(msg).split(/\s+/).splice(1); let flags = cmds.filter((o)=&gt;/^--/.test(o)).map((s)=&gt;s.toLowerCase()); let turns = cmds.filter((o)=&gt;!/^--/.test(o)).map((s)=&gt;parseFloat(s)||0.00); let tokens = msg.selected .map(o=&gt;getObj('graphic',o._id)) .filter(g=&gt;undefined !== g) ; flags.forEach(f=&gt;{ switch(f){ case '--clear': tokens.forEach(t =&gt; { if(playerCanControl(t,msg.playerid)){ removeTokenTurn(t.id); } }); break; case '--clear-all': if(playerIsGM(msg.playerid)){ clearTurnOrder(); } break; } }); tokens.forEach( t =&gt; turns.forEach( pr =&gt; addTokenTurn(t.id,pr))); flags.forEach(f=&gt;{ switch(f){ case '--sort-desc': if(playerIsGM(msg.playerid)){ sortTurnOrder(sorter_desc); } break; case '--sort-asc': if(playerIsGM(msg.playerid)){ sortTurnOrder(sorter_asc); } break; } }); } }); });
Awesome! Thank you so much!
1539721935
Kraynic
Pro
Sheet Author
When I first saw this thread pop up, I thought The Aaron would be along with a script.
1539724048
The Aaron
Pro
API Scripter
&nbsp;That’s my modus operandi. =D
Now all we need is a decent script for a new Star Wars film - lets hope The Aaron can provide that too !
1539770988
The Aaron
Pro
API Scripter
Hahahahaha. &nbsp;Off topic for this forum, sorry! =D
Haha can we also get the star wars script though?
1539808517
Gen Kitty
Forum Champion
Since the original question has been answered, I'll go ahead and close this thread.&nbsp; :)