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

Delay between macro commands

Is there a working method to delay commands in a multi-command macro? Previously discussed here: <a href="https://app.roll20.net/forum/post/319863/request-d" rel="nofollow">https://app.roll20.net/forum/post/319863/request-d</a>... I tried <a href="https://wiki.roll20.net/Script:Store_Commands" rel="nofollow">https://wiki.roll20.net/Script:Store_Commands</a> but that throws errors out of the box, not updated in a year so no longer compatible perhaps.
1490447687
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
If you mean with a script, sure, just don't think ones been written for that exact purpose. I've got a similar functionality in Roll20AM.
Well for example I would like a macro like this: !shaped-apply-defaults !shaped-expand-spells To be this: !shaped-apply-defaults &lt;500ms pause&gt; !shaped-expand-spells
Probably wont help, but i have been trying this for the shape shifting i want for the Druid, and i have had to write my own API script for it.
1490453753

Edited 1490454884
Thorsten
KS Backer
The way the chat is parsed, I don't think this is trivial. I tried this as a macro: Starting !wait 500 Ending And the output is: 10:51AMThorsten (GM): Starting Ending 10:51AM(From WAIT): 500 ms Which means macros don't wait for something to complete before going on to the next command to output into chat. That "From WAIT" line is a debug message in the !wait API I cobbled together. Edit: Okay, so what if "wait" could take a command, and then execute that after the wait. That might work. Or take multiple commands and execute them with a wait in between each. Which do you think would work best, here? What are your use cases? Is it preferable to specify a custom wait between each command, or should it be just a standard wait, and then execute commands in order with the specified wait in between? I can probably steal some code from GroupCheck to make this work. For reference, this is a wait script that does nothing but wait: // VERSION INFO var Wait_Author = "Thorsten"; var Wait_Version = "1.0"; var Wait_LastUpdated = 1490451480; // FUNCTION DECLARATION var WaitScript = WaitScript || {}; on("chat:message", function (msg) { if (msg.type != "api") return; if (msg.content.split(" ", 1)[0] === "!wait") { msg.who = msg.who.replace(" (GM)", "").split(" ", 1)[0]; msg.content = msg.content.replace(/&lt;br\/&gt;\n/g, ' ').replace(/({{(.*?)}})/g, " $2 "); var n = msg.content.split(" ", 2)[1]; if (!WaitScript.isPositiveInteger(n)) { &nbsp; &nbsp;sendChat("WAIT", "/w " + msg.who + " You did not give a wait time (in ms)."); &nbsp; &nbsp;return; } if (n &gt; 500) { &nbsp; &nbsp;sendChat("WAIT", "/w " + msg.who + " Waiting for more than 500ms is not supported, as it may crash the API sandbox."); &nbsp; &nbsp;return; } WaitScript.Wait(n); sendChat("WAIT", "/w " + msg.who + " " + n + " ms"); } }); on("ready", function () { log("-=&gt; Wait v" + Wait_Version + " &lt;=- &nbsp;[" + (new Date(Wait_LastUpdated * 1000)) + "]"); //log (Date.now().toString().substr(0, 10)); }); WaitScript.Wait = function (ms) { &nbsp; &nbsp; var d = new Date(); &nbsp; &nbsp; var d2 = null; &nbsp; &nbsp; do { d2 = new Date(); } &nbsp; &nbsp; while(d2-d &lt; ms); } WaitScript.isPositiveInteger = function (n) { &nbsp; &nbsp; return n &gt;&gt;&gt; 0 === parseFloat(n); }
Arno said: Well for example I would like a macro like this: !shaped-apply-defaults !shaped-expand-spells To be this: !shaped-apply-defaults &lt;500ms pause&gt; !shaped-expand-spells You'd have to ask Lucian to expand the script to allow you to use those two functionalities within one command.
The best way to stagger execution of API commands in a specific order would be to number them and then execute them in that order with the specific delay between them. !delay 1 500 token-mod ... !delay 2 2500 token-mod ... !delay 3 5000 token-mod ...
@SkyCaptain I don't understand the API well enough to implement something like that. Wouldn't this call !delay three times, each unaware of the other calls? Over to someone better versed in JS in general and the roll20 API in particular :).
1490474809
Lithl
Pro
Sheet Author
API Scripter
Thorsten B. said: @SkyCaptain I don't understand the API well enough to implement something like that. Wouldn't this call !delay three times, each unaware of the other calls? Yes, but the first one would wait 0.5s before doing something, the second would wait 2.5s, and the third one would wait 5s. Arno said: I tried <a href="https://wiki.roll20.net/Script:Store_Commands" rel="nofollow">https://wiki.roll20.net/Script:Store_Commands</a> but that throws errors out of the box, not updated in a year so no longer compatible perhaps. I'm the author. I haven't touched it because few people have used it (so adding features isn't a priority) and I haven't gotten bug reports. What's the error you got?