Hey all, 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: !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: 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 <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:65:16)
at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>: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. 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. 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&D session (which didn't involve any changes to the API at the console or mod library level). 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 here . /*
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 && 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 > 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" && msgTxt.indexOf(cmdName) !== -1 && 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) && command)
var delay_length = seconds * 1000;
else
return;
setTimeout(delayFunction(speaking, command, pid), delay_length);
};
});
on('ready',function(){
log("-=> Delay command loaded (!delay) <=-");
});