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

End of Turn Update

Hello all, Awhile back I was looking for a simple player-side command to end their character's turn and found this bit of code .  It worked perfectly, did exactly what I needed it to do, but it seems it was broken by the recent turn tracker update. The intended behavior is that, after a player ends their turn, it's supposed to push their token to the back of the initiative order.  Now, after the update, it instead removes the token from the turn tracker entirely, so in the last game I ran I had to manually select and re-add all participants in the combat at the end of every round.  Not insurmountable, but less than ideal. The code is below;  is there an easy fix here to allow me to go back to the intended behavior? on("chat:message", function(msg) { if (msg.type == "api" && msg.content.indexOf("!eot") !== -1) { var c = Campaign(); var pre_turnorder = c.get('turnorder'); if (!pre_turnorder) { return; } var turn_order = JSON.parse(c.get('turnorder')); if (!turn_order.length) { return; }; var turn = turn_order.shift(); var stop = 0; // Since I will be checking the player inside of another function return; wont work. var obj = findObjs({ _id:turn.id }); _.each(obj, function(obj) { }); if (stop == 1) { return; }; turn_order.push({ id: turn.id, pr: turn.pr, custom: "Turn Counter" }); Campaign().set("turnorder", JSON.stringify(turn_order)); turn_order = JSON.parse(c.get('turnorder')); turn = turn_order.shift(); sendChat(msg.who, "/em has ended their turn!"); var obj = findObjs({ _id:turn.id }); _.each(obj, function(obj) { if (obj.get("name") != "") { sendChat(" ", "/em " + obj.get("name") + " it is your turn!") }; if (obj.get("name") == "") { sendChat("(Game)", "Enemys Turn!") }; }); } }); Very much appreciate any help and insight;  thank you!
1645984019
The Aaron
Roll20 Production Team
API Scripter
This should work: on('ready', ()=> { on("chat:message", (msg) => { if (msg.type == "api" && msg.content.indexOf("!eot") !== -1) { let c = Campaign(); let pre_turnorder = c.get('turnorder'); if (!pre_turnorder) { return; } let turn_order = JSON.parse(c.get('turnorder')); if (!turn_order.length) { return; }; let turn = turn_order.shift(); // No-Op, commented out //let stop = 0; // Since I will be checking the player inside of another function return; wont work. // let obj = findObjs({ id: turn.id }); //_.each(obj, function(obj) { //}); // if (stop == 1) { return; }; turn_order.push({ ...turn, custom: "Turn Counter" }); Campaign().set("turnorder", JSON.stringify(turn_order)); turn_order = JSON.parse(c.get('turnorder')); turn = turn_order.shift(); sendChat(msg.who, "/em has ended their turn!"); let obj = findObjs({ id:turn.id }); _.each(obj, function(obj) { if (obj.get("name") != "") { sendChat(" ", "/em " + obj.get("name") + " it is your turn!") }; if (obj.get("name") == "") { sendChat("(Game)", "Enemys Turn!") }; }); } }); });
I once thought this was needed but in practice after having used one of the combat api's for a bit I realized that the button turns into a less useful thing.  Players will forget to press it, I will go to advance the turn and they will then advance their turn and BAM, now I'm cycling around and screwing up ACT entries cause of it.  In practice, I find it best to keep it under my control when turns advance, especially when legendary actions are at play.  
The Aaron said: This should work: Like a charm!  Thanks, The Aaron! @DM Eddie -- this is for a Savage Worlds hack, so my whole build is cobbled together from a bunch of different bits and pieces.  So far it's been working alright for me;  if the player doesn't click the button, I remind them, and I only do it for them if they've gone AFK for some reason.  If it becomes problematic, though, I'm definitely open to restricting the eot! command to GM-only.