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 Script broken?

1706975939

Edited 1706975962
Hey all,&nbsp; I had been using the Delay script and CFX to run some custom visual effects, but now it seems like Delay crashes the console. Here is an example that was working a few days ago but now causes the console to crash:&nbsp; !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} !delay .6 --!cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} !delay 1.2 --!cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} !delay 1.8 --!cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} !delay 2.4 --!cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} That still executes the first two lines without issue, but I believe the 2nd line causes the crash when executed, which reports the following error message:&nbsp; TypeError: Cannot read properties of undefined (reading 'get') TypeError: Cannot read properties of undefined (reading 'get') at apiscript.js:38997:44 at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:168:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:168:1), &lt;anonymous&gt;:70:8) at /home/node/d20-api-server/api.js:1762:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:461 I have narrowed the problem down to being the Delay script itself or its execution of the delayed command, because each of those command lines in the original function just fine on their own, each being a duplicate of the first, just delayed.&nbsp; I have also tested this with an isolated Token-mod command, which returns the same error message as above regardless of what the command was trying to do.&nbsp; I am very confused as to why this was all working fine for the past week and broke only yesterday when I was prepping some final setup for a D&amp;D session (which didn't involve any changes to the API at the console or mod library level).&nbsp; Thanks in advance for any help you can provide! If needed, here is the Delay API that I currently have installed, which was the most recent version that I could find&nbsp; here .&nbsp; /* Delay Function / Command by Kastion the Scriptomancer Profile: <a href="https://app.roll20.net/users/3173313/kastion" rel="nofollow">https://app.roll20.net/users/3173313/kastion</a> Syntax: !delay [seconds] \\ [speaker] -- [command] */ function processInlinerolls(msg) { if(_.has(msg,'inlinerolls')){ return _.chain(msg.inlinerolls) .reduce(function(m,v,k){ var 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; } } function delayFunction(speaker, output, pid) { return function() { if (speaker.length &gt; 0) { var token = findObjs({ _pageid: Campaign().get("playerpageid"), _type: "graphic", _name: speaker.trim()}); var char = ""; } else var token = ""; if (token.length) { _.each(token, function(obj) { var char = getObj("character", obj.get("represents")); if (char) sendChat("character|" + char.id, output.trim()); else sendChat(speaker, output.trim()); }); } else sendChat(speaker, output.trim()); } } on("chat:message", function(msg) { if('api' !== msg.type ) { return; } var cmdName = "!delay"; var msgTxt = msg.content; if(msg.type == "api" &amp;&amp; msgTxt.indexOf(cmdName) !== -1 &amp;&amp; playerIsGM(msg.playerid)) { var inline_rolls = processInlinerolls(msg); var seconds = msg.content.split(' ')[1]; var speaking = msg.content.split('\\\\')[1]; var command = inline_rolls.substring(inline_rolls.indexOf('--')+2); var pid = msg.playerid; if (speaking) speaking = speaking.split('--')[0]; else speaking = ""; if (!isNaN(seconds) &amp;&amp; command) var delay_length = seconds * 1000; else return; setTimeout(delayFunction(speaking, command, pid), delay_length); }; }); on('ready',function(){ log("-=&gt; Delay command loaded (!delay) &lt;=-"); });
1706978659
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Rocklobster. I saw another post concerning the delay script yesterday, but cannot find it now. Was that yours? (Just trying to consolidate reports for passing on)
1706979318

Edited 1706982783
timmaugh
Pro
API Scripter
Hey, Rocklobster... just as an alternative, the MetaScriptToolbox offers a way to delay a command line by adding a tag like this to your command: {&amp;delay 0.3} That would delay the message where that tag was encountered by .3 seconds. With the Toolbox installed, then, your full set of commands would become: !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} {&amp;delay 0.6} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 1.2} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 1.8} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 2.4} EDIT: Had extra ampersands in my tags. Fixed, now.
keithcurtis said: Hi Rocklobster. I saw another post concerning the delay script yesterday, but cannot find it now. Was that yours? (Just trying to consolidate reports for passing on) Yeah, that was mine, and was posted in haste right before a DnD session. This morning after looking at the problem closer and narrowing it down to Delay, i ended up deleting the original post since it has superfulous conjecture about errors.&nbsp;
timmaugh said: Hey, Rocklobster... just as an alternative, the MetaScriptToolbox offers a way to delay a command line by adding a tag like this to your command: {&amp;delay 0.3} That would delay the message where that tag was encountered by .3 seconds. With the Toolbox installed, then, your full set of commands would become: !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} {&amp;delay 0.6} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 1.2} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 1.8} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 2.4} EDIT: Had extra ampersands in my tags. Fixed, now. Thank you for the alternate solution Timmaugh, I will have to give that a shot when I have a moment!
timmaugh said: Hey, Rocklobster... just as an alternative, the MetaScriptToolbox offers a way to delay a command line by adding a tag like this to your command: {&amp;delay 0.3} That would delay the message where that tag was encountered by .3 seconds. With the Toolbox installed, then, your full set of commands would become: !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} {&amp;delay 0.6} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 1.2} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 1.8} !cfx DestructiveWave1 @{target|Yourself|token_id} @{target|Yourself|token_id} &nbsp; {&amp;delay 2.4} EDIT: Had extra ampersands in my tags. Fixed, now. Hey Timmaugh,&nbsp; So I went and tested this out and I'm now encountering something I haven't encountered before. Using that delay format, the !cfx commands that are being delayed are also being applied concurrently not just to the target token, but also to several other tokens/objects I did not click on. The extra 'targets' that it runs include but are quite likely not limited to: — Roll20 VTT Place Light objects/tokens regardless of object/gm/map/DL layers — Any and all map art or objects in the map layer — The turn marker tokens from the Combat Master script that highlight current and next turns on the VTT&nbsp; Can you think of any reason why it would be running the effects on art objects and map layer contents? It doesn't affect player and npc tokens that get moved between layers, so I'm thinking that it currently affects all tokens/objects without an associated character sheet.&nbsp;&nbsp;
1707139843
timmaugh
Pro
API Scripter
Hmm... There shouldn't be anything about that command that adds/modifies targets, nor which adds/modifies your selected tokens. In fact, you shouldn't have any selected tokens (as far as the API is concerned) because you have targeting statements in your command line (they prevent the message having selected tokens). That makes me wonder if Combat Master (or another script) is taking action in response to the cfx command somehow. What happens if you disable CombatMaster and run the above command series?
1707145572
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I don't know if this adds anything to the discussion, but the forum post for CFX does mention that the version posted there was written to work with the delay script.
1707147227

Edited 1707147285
timmaugh &nbsp;said: Hmm... There shouldn't be anything about that command that adds/modifies targets, nor which adds/modifies your selected tokens. In fact, you shouldn't have any selected tokens (as far as the API is concerned) because you have targeting statements in your command line (they prevent the message having selected tokens). That makes me wonder if Combat Master (or another script) is taking action in response to the cfx command somehow. What happens if you disable CombatMaster and run the above command series? I gave disabling Combat Master a try, but it didn't affect the problem (other than its turn marker objects being removed when I ended the turn order I was using to test things before disabling the script, so there were two less objects being affected on the VTT).&nbsp; A thought I had is that I read recently in a forum somewhere, I think mostly for some of the MetaScriptToolbox dependencies, that script load order is sometimes important, so I'm attaching a screenshot of my scripts I have installed for this game. Hopefully it will help us narrow down the problem.&nbsp;
1707408246

Edited 1707408264
For the time being, I'm just going to pull all the visual effects out of character abilities and store them in a separate character sheet to be called from later, if/when a solution to this problem can be found.&nbsp;