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] End Of Turn

My players suggested this, since I'm a terrible Gm and occasionally push through the initiative tracker too quickly. This script allows players to end their own turns by typing !eot. The result is their names dropping to the bottom, as well as a chat display that has them say eot, and finally, it announces who's up in the turn order. If it's not a player, it announces "Monster's turn!" <a href="https://gist.github.com/anonymous/6047312" rel="nofollow">https://gist.github.com/anonymous/6047312</a>
Great Idea! I get the error&nbsp;Unexpected identifier when I try to copy this script. I tried changing Battle Master to GM, but no luck.&nbsp;
Not sure why? I'll re-gist it and see if that works
<a href="https://gist.github.com/anonymous/6116583" rel="nofollow">https://gist.github.com/anonymous/6116583</a>
not sure If If I posted an incomplete script last time, but this is the one I personally use in my games.
I"'m not sure but an update may have caused an issue. I used the original posted script without issue then suddenly got the same error message described. Thanks for the repost I'll give it a try.
Let me know if it works, because I'm still using the script, and it's working fine. Most of my players even have macro's set up so they can use an EOT button.
I had the error too last night, and did some trouble shooting. It only had a problem when being run in conjunction with another script, and when its the only active script, it runs perfectly. If I had to guess as to the cause, it's using the Campaign() function, which might be interfering with other scripts (It shouldn't, but that's the only thing that my other scripts don't touch, and they're working fine together). Will try to dig further into this, but considering moving this to the bugs forum.
1375335686
Alex L.
Pro
Sheet Author
Emile l. said: I had the error too last night, and did some trouble shooting. It only had a problem when being run in conjunction with another script, and when its the only active script, it runs perfectly. If I had to guess as to the cause, it's using the Campaign() function, which might be interfering with other scripts (It shouldn't, but that's the only thing that my other scripts don't touch, and they're working fine together). Will try to dig further into this, but considering moving this to the bugs forum. the fact you are missing semi-colons all over the place may not help, I know javascript is forgiving of that sort of thing but still.
I've been messing with it since it went down. Cleaned it up, formated it properly, and it's still acting up. Funny thing is that when I use multiple scripts on Dev server it's working fine though. Thinking it's probably buggy.
This is a great idea. I'm using this in combination with the Auto initiative script to make combat flow faster. And my players sometimes end their turn without voicing it very well. So this command is great! Simple, but its just what I needed. Thank you so much.&nbsp;
No problem!
1375830989

Edited 1375833470
First, I have no coding experience at all, so I'm very proud of what I've accomplished here. I changed your script very slightly. Basically all I did was change the chat output, but I am still very impressed that I didn't find a way to break your script. This is what the chat output looks like now. Edit: Then I had to go one step further, and now I broke it. :P Edit2:&nbsp; I fixed it again. :P
I tried using it in combination with Auto Init and the health change announce scripts but got the error "unexpected token var" Any help on that? I used exactly the code here and have no idea what's wrong with it
There's a few things that are semi broken in the API right now, and the turn order is one of them. It'll work out eventually. Until then (and its only a work around) enable the auto init script at the beginning of a battle, then disable it and enable eat.
I have some players who control multiple characters, and I'm having the script display only the message for ending turns (so it only shows when players end their turn, which is all I'm looking for). &nbsp;Since some players control multiple characters, I'm trying to get the script to readout sendchat("DM","/desc "+the name of the token that ended their turn+" has ended their turn") but I'm not sure how to do this exactly.
Close. sendChat(msg.who,"/me has ended his/her turn")
Oh. For multiple characters... Would take me a few minutes to build. Would be easy though, create a var for turn.id, then getObj the id to find character name, and use that as the sendchat who.
1378324722

Edited 1378387043
I expended on this idea, the following script will only allow the person who's turn it is to end a turn. This also has alot more handling for possible errors.&nbsp; on("chat:message", function(msg) { &nbsp; &nbsp; if (msg.type == "api" &amp;&amp; msg.content.indexOf("!eot") !== -1) { &nbsp; &nbsp; &nbsp; &nbsp; var c = Campaign(); &nbsp; &nbsp; &nbsp; &nbsp; var pre_turnorder = c.get('turnorder'); &nbsp; &nbsp; &nbsp; &nbsp; if (!pre_turnorder) { return; } &nbsp; &nbsp; &nbsp; &nbsp; var turn_order = JSON.parse(c.get('turnorder')); &nbsp; &nbsp; &nbsp; &nbsp; if (!turn_order.length) { return; }; &nbsp; &nbsp; &nbsp; &nbsp; var turn = turn_order.shift(); &nbsp; &nbsp; &nbsp; &nbsp; var stop = 0; // Since I will be checking the player inside of another function return; wont work. &nbsp; &nbsp; &nbsp; &nbsp; var obj = findObjs({ _id:turn.id }); &nbsp; &nbsp; &nbsp; &nbsp; _.each(obj, function(obj) { &nbsp; &nbsp; &nbsp; &nbsp; if (obj.get("name") != "") { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (obj.get("name") != msg.who){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat("(Game)", "/w " + msg.who +" Please do not try to end someone elses turn. " + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Also, Remember to use this command as your character."); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat("(Script)", "/w gm " + msg.who + " tried to end the turn for " + obj.get("name") + "."); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stop = 1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; if (stop == 1) { return; }; &nbsp; &nbsp; &nbsp; &nbsp; turn_order.push({ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id: turn.id, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pr: turn.pr, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; custom: "Turn Counter" &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; Campaign().set("turnorder", JSON.stringify(turn_order)); &nbsp; &nbsp; &nbsp; &nbsp; turn_order = JSON.parse(c.get('turnorder')); &nbsp; &nbsp; &nbsp; &nbsp; turn = turn_order.shift(); &nbsp; &nbsp; &nbsp; &nbsp; sendChat(msg.who, "/em has ended their turn!"); &nbsp; &nbsp; &nbsp; &nbsp; var obj = findObjs({ _id:turn.id }); &nbsp; &nbsp; &nbsp; &nbsp; _.each(obj, function(obj) { &nbsp; &nbsp; &nbsp; &nbsp; if (obj.get("name") != "") { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat(" ", "/em " + obj.get("name") + " it is your turn!") &nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp; &nbsp; if (obj.get("name") == "") { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat("(Game)", "Enemys Turn!") &nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp;} }); Let me know what you think :)&nbsp;
Oh awesome, thanks a ton, this works out well.
Love it, except for being GM. I eliminated the safety code for people ending eachother's turns since my groups are pretty mature. Works like a charm for my purposes, but otherwise i'd add &amp;&amp; msg.who != msg.who.indexOf("GM") to ensure Gm can swap turns as he/she pleases.