[Script Update] TurnMarker1 -- Now with GM activated Ping-Pulling

1473730485

Edited 1473865807
The Aaron
Pro
API Scripter
Update v1.3.7  -- Added external function TurnMarker.TurnOrderChange() to notify of a script change to turn order. Update v1.3.6 -- Fixed crash with GroupInitiative! Update v1.3.5  -- Added a new configuration for auto pulling GMs.   !tm autopull npcs none -- Does not auto pull GMs (default) npcs -- Pulls GMs for any npc tokes (where NPC tokens are not controlled by anyone and neither are their represented characters) all  -- pull for all tokens in the turn order. I also added buttons for EOT (players and GM) and for Reset (GM only, will prompt for number to reset to) Additionally, I added an optional argument to reset to specify the number to reset to: !tm reset 5 Update v1.3.4 --GMs can now click the image in the announcement to be ping-pulled to the token in question. At request I've added clicking the announcement image to pull the GM to the token clicked.  This only works for GMs (sorry players, no messing with your GM's screen!). Git:  https://github.com/shdwjk/Roll20API/blob/master/Tu... Original Thread:  https://app.roll20.net/forum/post/931415/script-tu... 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.
1473759681
Ziechael
Pro
Sheet Author
**cough** as mentioned in the other thread, add the 'next turn' button for players to the chat output **cough**
1473761197
Ravenknight
KS Backer
Awesome!!
1473766575
The Aaron
Pro
API Scripter
@Ziechael Yeah, yeah. And something about stepping on my toes...  :). I'll add that. Anything else custom I added?
1473767102
Ziechael
Pro
Sheet Author
That's it for that one... I think... ;)
1473768146
Franky H.
Roll20 Mod Team
One thing to note, the tracker doesn't reset between combats, so i have to manually !tm reset when a new combat happens
1473770550
Ravenknight
KS Backer
Franky H. said: One thing to note, the tracker doesn't reset between combats, so i have to manually !tm reset when a new combat happens I actually like this since I tend to close the tracker once in a while without ending the combat. :/ Perhaps as an option?
1473770683
The Aaron
Pro
API Scripter
!tm reset You can do that as a macro to have a button to click to reset it.
1473814493
The Aaron
Pro
API Scripter
Updated to 1.3.5 -- now with pings, buttons and auto pull!
1473836983
Ravenknight
KS Backer
For some reason this version breaks my Group-initiative. As long as I add the tokens to the turnorder one by one it works flawlessly. New buttons and all. :) Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: TypeError: Cannot read property 'bind' of undefined TypeError: Cannot read property 'bind' of undefined at Function._.bind (/home/node/d20-api-server/node_modules/underscore/underscore.js:712:27) at _.chain.filterObjs.reduce.map._.chain.handleExternalTurnOrderChange (apiscript.js:14217:19) at apiscript.js:62:5 at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9) at notifyObservers (apiscript.js:61:6) at apiscript.js:1019:9 at /home/node/d20-api-server/node_modules/underscore/underscore.js:880:21 at apiscript.js:1060:13 at checkFinishedOps (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:758:7) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:838:8)
1473849346
Alexander
Pro
Sheet Author
Followed this topic! Very hard work, thank you.
1473852515
The Aaron
Pro
API Scripter
Ravenknight said: For some reason this version breaks my Group-initiative. As long as I add the tokens to the turnorder one by one it works flawlessly. New buttons and all. :) Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: TypeError: Cannot read property 'bind' of undefined TypeError: Cannot read property 'bind' of undefined at Function._.bind (/home/node/d20-api-server/node_modules/underscore/underscore.js:712:27) at _.chain.filterObjs.reduce.map._.chain.handleExternalTurnOrderChange (apiscript.js:14217:19) at apiscript.js:62:5 at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9) at notifyObservers (apiscript.js:61:6) at apiscript.js:1019:9 at /home/node/d20-api-server/node_modules/underscore/underscore.js:880:21 at apiscript.js:1060:13 at checkFinishedOps (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:758:7) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:838:8) Hmmm. I'll give that a look.
1473858691
The Aaron
Pro
API Scripter
Ravenknight said: For some reason this version breaks my Group-initiative. As long as I add the tokens to the turnorder one by one it works flawlessly. New buttons and all. :) Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: TypeError: Cannot read property 'bind' of undefined TypeError: Cannot read property 'bind' of undefined at Function._.bind (/home/node/d20-api-server/node_modules/underscore/underscore.js:712:27) at _.chain.filterObjs.reduce.map._.chain.handleExternalTurnOrderChange (apiscript.js:14217:19) at apiscript.js:62:5 at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9) at notifyObservers (apiscript.js:61:6) at apiscript.js:1019:9 at /home/node/d20-api-server/node_modules/underscore/underscore.js:880:21 at apiscript.js:1060:13 at checkFinishedOps (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:758:7) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:838:8) Update v1.3.6 -- Fixed crash with GroupInitiative!
1473859282
Franky H.
Roll20 Mod Team
He did it! The absolute mad man. You've pushed out 2 new versions in like a day. Take a nap :P
1473860027
The Aaron
Pro
API Scripter
Hahahaha.. It's all about having a good deploy system... =D Mine handles bumping the version number (in the script and the script.json), setting the updated timestamp, checking some common code things, creating branches in my fork of the roll20 api scripts repo, copying the files to all the places and creating the commit messages.  That makes deploying quite a bit easier. =D
1473861180
The Aaron
Pro
API Scripter
Franky H. said: He did it! The absolute mad man. You've pushed out 2 new versions in like a day. Take a nap :P What you're really seeing is a spark of my regular self.  I've been limited on my Roll20 interactions for the last 6 months as I've been working on a major move across country.  I'll be moved by the end of the month though and I've been getting a few hours here and there to jump on stuff. =D  Just you wait!  Once I'm a fully operational battlestation again... unicorns!  =D Incidentally, every time I see your avatar, I think of this card from Cthulhu Realms =D:
1473861425

Edited 1473861457
Ravenknight
KS Backer
The Aaron said: Ravenknight said: For some reason this version breaks my Group-initiative. As long as I add the tokens to the turnorder one by one it works flawlessly. New buttons and all. :) Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: TypeError: Cannot read property 'bind' of undefined TypeError: Cannot read property 'bind' of undefined at Function._.bind (/home/node/d20-api-server/node_modules/underscore/underscore.js:712:27) at _.chain.filterObjs.reduce.map._.chain.handleExternalTurnOrderChange (apiscript.js:14217:19) at apiscript.js:62:5 at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9) at notifyObservers (apiscript.js:61:6) at apiscript.js:1019:9 at /home/node/d20-api-server/node_modules/underscore/underscore.js:880:21 at apiscript.js:1060:13 at checkFinishedOps (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:758:7) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:109:36), <anonymous>:838:8) Update v1.3.6 -- Fixed crash with GroupInitiative! Thanks Aaron, love it.
1473861453

Edited 1473863159
tox
Pro
Hey Aaron! First of all, thanks for your awesome scripts. I use some of them in my campaign (mainly TurnMarker and Group Initiative). I noticed that you changed the visibility of some of your TurnMarker functions with the latest version - which kind of broke one of my .. let's call it helper scripts. I'll elaborate a bit: I utilize a script that automatically sets the dead status marker for a monster token that is brought to <1 hp and removes its turn order entry (I'm using your individual group initiative option; it is quite nice to remove clutter automatically). I came up with this script because manually deleting slain tokens from the turn order and setting the statusmarker was annoying; but deleting the dead tokens was not really an option because in combat my players kept forgetting that there are corpses littered around and stopped interacting with them (which made me a sad gm). When a monster is at the top of the initiative order and is slain (attacks of opportunity and such) the removal of the topmost token in the turn order by API obviously stoppped your TurnMarker script until the next round advancement request. So I added a call to your TurnMarker.TurnOrderChange function to compensate for the lack of a turnorderchange event. For now I altered your script so that turnOrderChange is visible again, but do you think it is possible in future releases to have it accessable by other scripts again? Or is there another possibility to achieve the same functionality that I missed? The script I'm talking about, if further clarification is needed. The relevant call  is in line 89:  http://pastebin.com/Xjxx2jWU
1473861819
Franky H.
Roll20 Mod Team
The Aaron said: Franky H. said: He did it! The absolute mad man. You've pushed out 2 new versions in like a day. Take a nap :P What you're really seeing is a spark of my regular self.  I've been limited on my Roll20 interactions for the last 6 months as I've been working on a major move across country.  I'll be moved by the end of the month though and I've been getting a few hours here and there to jump on stuff. =D  Just you wait!  Once I'm a fully operational battlestation again... unicorns!  =D Incidentally, every time I see your avatar, I think of this card from Cthulhu Realms =D: Incidentally, its a skin for the game League of Legends called Surgeon Shen. He's a ninja tank.
1473862072
The Aaron
Pro
API Scripter
Ah.  Interesting.  I think the function you want to call is actually handleExternalTurnOrderChange.  If you change line 675 to this:     return { TurnOrderChange: handleExternalTurnOrderChange,         CheckInstall: checkInstall,         RegisterEventHandlers: registerEventHandlers     }; That would be the minimal change to let your existing script still work unmodified. Future versions of the script will expose an interface for external scripts to interface with them directly, but that's a few months off.  Let me know if the above works correctly for you, that's the function GroupInitiative calls when it modifies the turn order, so it's the one I would probably expose.  If that works, I'll put the above in the main line for now, until I have a better alternative.
1473863048

Edited 1473863588
tox
Pro
Yep, that works too. I'm only scratching the surface so far in understanding your code, so out of curiosity, what is the difference between calling turnOrderChange and handleExternalTurnOrderChange? Edit: I just noticed, when I call TurnOrderChange the turn announcement to chat correctly uses the "to be deleted from turn order" token image as previous turn image. While when calling handleExternalTurnOrderChange it will use the "previous previous" token image (basically the same as when I delete the turn order entry before making the turn announcement).
1473864555
The Aaron said: Hahahaha.. It's all about having a good deploy system... =D I'd love to have something like that for actually installing the scripts. A script that pulls the newest versions directly from the official repo. I hardly can install new versions as quickly as you push them out! 
1473865055
The Aaron
Pro
API Scripter
handleExternalTurnOrderChange() will deal with things like "The marker's Turn is Next" and "The Turn Order has been hidden" and "I need to play animations and adjust the Marker size" and such.  It additionally defers calling through to turnOrderChange() to avoid some race conditions with external scripts finishing up changes to the TurnOrder entries. handleTurnOrderChange() does some checks to make sure there still are entries in the turn order.  It's intended as the entry point for the Roll20 change:campaign:turnorder event. turnOrderChange() is the internal function that just deals with what the script should do when the turn order has changed.  What to show, where to move things, etc. I'll try to come up with a solution to having the killed entity show up correctly.  This is my second oldest script (right behind the Mystara Calendar) so the code is quite ugly. =D  I cleaned up quite a bit of its structure while making this change, which is why some of the functions that should be internal are now hidden from external scripts.  I haven't done anything for the actual algorithms and data organization though, which I need to do to make it behave more sanely.  I'd also like to update the output to be less.... clunky. =D  All in good time, of course. Honestly, I'm considering getting rid of the part that tells you who's turn it was. =D  It's somewhat redundant with the prior message, though it makes a nice bookend to who's actions are probably above it in the chat log.  Anyway, if you can live with that output for now, I'll go ahead and push that change.
1473865115
The Aaron
Pro
API Scripter
Arthur B said: The Aaron said: Hahahaha.. It's all about having a good deploy system... =D I'd love to have something like that for actually installing the scripts. A script that pulls the newest versions directly from the official repo. I hardly can install new versions as quickly as you push them out!  I actually have an idea for that and had almost written it when the 1-click installs came out.  I still have some ideas around doing that though, which I might do at some point. =D
1473865989
tox
Pro
Thanks for the explanation, that was really helpful and cleared up an issue I had when the killed token was right before the round counter. The Aaron said: Honestly, I'm considering getting rid of the part that tells you who's turn it was. =D I would honestly prefer that, but that may just be me. The turn announcement already takes up quite some space in the chat, so anything that makes it more manageable on smaller screens would be a plus in my book. And as you said, it is a little bit redundant. Anyway, if you can live with that output for now, I'll go ahead and push that change. For sure I can live with the output. Hell, I could have lived with 1.3.4... but those end of turn buttons are a damn neat feature. Thanks again for the help, and for making those awesome scripts!
1473866003
The Aaron
Pro
API Scripter
Update v1.3.7 -- Added external function TurnMarker.TurnOrderChange() to notify of a script change to turn order. I went ahead and pushed this up. @Franky H. -- Here's what my deploy script does for this.. =D   There's still a few manual checkin steps and adding/updating the pull request (haven't gotten to automating that yet.. ), but this takes care of most of the fiddly bits. =D
1473866084
The Aaron
Pro
API Scripter
tox said: For sure I can live with the output. Hell, I could have lived with 1.3.4... but those end of turn buttons are a damn neat feature. Thanks again for the help, and for making those awesome scripts! Cool, it is done!  =D  Enjoy!
1473870514
The Aaron said: Update v1.3.7 -- Added external function TurnMarker.TurnOrderChange() to notify of a script change to turn order. I went ahead and pushed this up. @Franky H. -- Here's what my deploy script does for this.. =D   There's still a few manual checkin steps and adding/updating the pull request (haven't gotten to automating that yet.. ), but this takes care of most of the fiddly bits. =D I'm not Franky, but I'll be frank: I need to have a look into gulp....
1473871087
Franky H.
Roll20 Mod Team
I am Franky, and I need to learn to do APIs
1473872265
The Aaron
Pro
API Scripter
Arthur B said: I'm not Franky, but I'll be frank: I need to have a look into gulp.... I'm only using gulp for the command line and some minor tasks.  Most of that is a custom Node module I wrote to handle it. =D
1473872541
Is there something else beyond the command line?
1473873988
The Aaron
Pro
API Scripter
For Gulp -- Ts a task runner, pipeline based, with smart paralellizing of tasks.  For My Deploy System (TheAaronDeploy?) -- There are a ton of other specialty tasks. Validation between the various files and versions, manipulation a of the code to move migrate the format of things, etc. 
1478805998

Edited 1478806042
Alexander
Pro
Sheet Author
Hi Aaron. I hope you are well and not misbehaving. I have been good.  I was running my game as usual last night. I noticed that the turn order tracker was sending the 'ward gif' to two different way points as if it were moving with space and click. I removed the map layer and had a look if there were any stuck tokens hidden under the map, then I checked the other layers and found nothing, it seems its just movement pinging to two random locations for no reason . I took to the other page ( I only have two pages on my game ) and it does not have the same problem. So I don't know what is going on and thought you may be able to help sort it out. Was driving me crazy yesterday and everytime a token moves the 'initiative ward gif' also moves to these random locations. No rush.
1478808837
The Aaron
Pro
API Scripter
Probably the token that is in the turnorder is on that other page...  I should really fix that...
1478891911
Alexander
Pro
Sheet Author
There were two tokens on the other page, and from theirs positions on the page it looked almost as if the ward was tracking them. However I deleted the two tokens from that page and the ward is still following two unknown items every time a token moves on the initiative tracker. I am going to PM you.
1479020299

Edited 1479026653
Hello Aaron!  Probably because the feature is experimental, but the rotate or toggle auras arn't working for me in version 1.3.7 (I pulled the code last night).  Also I'm not seeing any turn marker behind the selected token.  Fixed this... I think.  Something to do with the players being on a different page than I was. Feature request: Add an option to disable the ping on auto-pull if possible.  Or possibly it's simply simulating the shift+ping to trigger the auto-pull.  Either way it's a pretty cool feature. Do you have library of your roll20 scripts or are they going to make into the roll20 api script library eventually?  You linked recursive tables recently and I thought that was pretty darn cool! Hope things are going well for you,
1479043617

Edited 1479046130
The Aaron
Pro
API Scripter
Hmm. I probably broke the auras bit, I'll test that.  The ping pull uses the send ping, so can't be done without showing the ping unfortunately.  All of my released scripts are in the Roll20 repo, but you can also look though my repo if you want: http://github.com/shdwjk/Roll20API
Hello! I LOVE this script! It's beyond helpful for keeping my players attentive to what's actually happening in combat, especially in dark dungeons! I tracked this thread down to ask about Condition Tracking. First, is there a feature for this within your script already that I am missing? For example: Haste duration 6 rounds. Is there a way to get it to count that down and let Chat know when the duration has expired? There are other scripts which do exactly that, but I am afraid to stack them with this because I worry it might bug out. Frankly, if I have to choose condition tracking or your script, I choose yours. I can keep track of conditions on paper if I have to haha, but man would it be nice to have built in! Thanks for your hard work!
1481863942
The Aaron
Pro
API Scripter
That's definitely on my to-do list.  I've been super busy this year and especially the last couple weeks (new baby, 15 days old today!).  I'm trying to get caught up on the forums, then I'll be working on scripts.  No timeline as yet. =D  (And you're welcome, I enjoy being helpful!)
I actually managed to get this functionality, by mixing this and trackerjacker!
1483750131

Edited 1483750161
Alexander
Pro
Sheet Author
Happy New Year The Aaron.  I was hoping to make the token different for this script (Give it some Ravenloft flavour) and all I tried was to change the URL for the image location. http://www.isle-decorate.com/beta/strahdtraker.png It did not work and my image did not appear and the old one, even with the changed URL was still functioning. You must have built the it well. I even tried flushing my DNS. Nada.
1483750397
The Aaron
Pro
API Scripter
Howdy!  The issue is that it's stored in state.  On my long todo list is fixing that.  bump the schema version by .1 and it should sort it out. You might need to delete any of the orange swirls it's already made.
1483786962

Edited 1483788848
Alexander
Pro
Sheet Author
One thing I have noticed is that when I enter the URL of your default image in my browser it downloads automatically. Now thinking straight, I changed my image to be hosted on roll20s amazon server. https://s3.amazonaws.com/files.d20.io/images/27072... Yet when I go there with my browser it views the image and does not automatically DL like your default image. Mr The Aaron, I changed the schema up to 1.81 Added my URL for the 'tracker' png image. For reference, the error message generated was: TypeError: Cannot read property 'id' of undefined TypeError: Cannot read property 'id' of undefined at getMarker (apiscript.js:266:37) at startMarker (apiscript.js:640:22) at dispatchInitiativePage (apiscript.js:662:13) at Object.registerEventHandlers (apiscript.js:671:9) at apiscript.js:686:13 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:144:34), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:144:34), <anonymous>:70:8) at checkForReady (/home/node/d20-api-server/api.js:1205:12) at /home/node/d20-api-server/api.js:1284:9 at c (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:14:64) I suspect this has all to do with the files.d20.io directory located where the original image is. https://s3.amazonaws.com/files.d20.io/images
1483803810
The Aaron
Pro
API Scripter
AH!   Sorry, sleepy brain.  The image must be in your user library for it to work.  Getting the URL is a bit complicated... without a script... =D on('ready',function(){     'use strict';     var getCleanImgsrc = function (imgsrc) {        var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|original|max)(.*)$/);        if(parts) {           return parts[1]+'thumb'+parts[3];        }        return;     };     on('chat:message',function(msg){         if('api' === msg.type && msg.content.match(/^!user-image/) && playerIsGM(msg.playerid) ){              let who=getObj('player',msg.playerid).get('_displayname'),                 output = _.chain(msg.selected)                     .map( s => getObj('graphic',s._id))                     .reject(_.isUndefined)                     .map( o => o.get('imgsrc') )                     .map( getCleanImgsrc )                     .reject(_.isUndefined)                     .map(u => `<div><img src="${u}" style="max-width: 3em;max-height: 3em;border:1px solid #333; background-color: #999; border-radius: .2em;"><code>${u}</code></div>`)                     .value()                     .join('') || `<span style="color: #aa3333; font-weight:bold;">No selected tokens have images in a user library.</span>`                     ;             sendChat('UserImage',`/w "${who}" <div>${output}</div>`);         }     }); }); Just select a graphic (or graphics) and run: !user-image It will output the urls: You can then copy the url you want and paste it into your modified copy of TurnMarker1, bump the schemaVersion by .1 and bob's yer uncle.  Let me know if you have any other issues, sorry I haven't gotten around to adding a user settable image to it yet.
1483808471

Edited 1483809511
Alexander
Pro
Sheet Author
I managed to do this. There were two schema I had to update +0.1 Then the image url in my library, thanks to your script, was located. Works. Fingers crossed. Of course I will mess about with paint.net and find a decent turnorder token to use, the default one is probably the best. Clear, visible, and directive.    Edit: I'll just muck around and upload a couple of possible ideas.
1483809179
The Aaron
Pro
API Scripter
Wow, that's very cool.  Is that an original image, or one pulled off the internet? (The one I have in there now is shamefully pulled from the internet, I should really replace it.)
1483809561

Edited 1483809583
Alexander
Pro
Sheet Author
There are so easy to make but time consuming, yeeeah unfortunately though I did pull them off the internet and then I just shop them to how I need them to look.
1483812443
The Aaron
Pro
API Scripter
no worries. =D  Looking good. =D
If you want some image options Aaron, just give me some rough sketches and I'll knock some out in photoshop.
1483832549

Edited 1483837042
The Aaron
Pro
API Scripter
Hey, that's cool. =D  I'll see what I can come up with at some point.  I was thinking when I get into the script and rewrite it, I should just have a selection of genre appropriate images.  =D Maybe some thoughts on what might make sense?  Here's a breakdown off the top of my head (I'm totally not saying go make a all these.. =D): Fantasy Hack'n'Slash Dark Gothic Horor Mystic Cartoony ( Pok√©mon ? ) Modern Plain Military Espionage Sci Fi Startreky Star Warsy H.R. Gigiery / Grimdark Technical Artsy Sketchy Neon
1483871993
Alexander
Pro
Sheet Author
You could also try ones that blend into the surroundings. I can show you what I mean. I can try to make a few too.