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

[Help] Trying to create a Script for tracking downtime activities.

1655987673
Julexar
Pro
API Scripter
Thanks for all the Help you guys! I wouldn't have been able to get this far without you. Really appreciate it! Here's the newest Version with a bit of rework and redesign to make everything look nicer. GitHub Gist
1656310209
Julexar
Pro
API Scripter
Little question, as I couldn't find it... - is there a way to modify an existing tool proficiency to have Expertise (using ChatSetAttr or similar APIs)?
1656324598
Julexar
Pro
API Scripter
Another thing, I've added the Handout logging but it seems broken as I always get the following error message and I don't know why or how I can make it stop.. RangeError: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded at IO.emit (events.js:314:20) at Client._write (/home/node/d20-api-server/node_modules/websocket-driver/lib/websocket/driver/base.js:158:25) at Client._sendFrame (/home/node/d20-api-server/node_modules/websocket-driver/lib/websocket/driver/hybi.js:270:10) at Client.onMessageReady (/home/node/d20-api-server/node_modules/websocket-driver/lib/websocket/driver/hybi.js:225:12) at Client.<anonymous> (/home/node/d20-api-server/node_modules/websocket-driver/lib/websocket/driver/hybi.js:231:24) at pipe (/home/node/d20-api-server/node_modules/websocket-extensions/lib/pipeline/index.js:37:40) at Pipeline._loop (/home/node/d20-api-server/node_modules/websocket-extensions/lib/pipeline/index.js:44:3) at Pipeline.processOutgoingMessage (/home/node/d20-api-server/node_modules/websocket-extensions/lib/pipeline/index.js:18:8) at Extensions.processOutgoingMessage (/home/node/d20-api-server/node_modules/websocket-extensions/lib/websocket_extensions.js:137:20) at Client.frame (/home/node/d20-api-server/node_modules/websocket-driver/lib/websocket/driver/hybi.js:229:24) My code looks like this: setHandoutDesc = function(playerid,num,description) {         num=Number(num);         let handout=findObjs({             _type: 'handout',         });         let id;         _.each(handout,function(object) {             let name=object.get('name');             let injournal=object.get('inplayerjournals');             if (name.includes("Downtime Activities")) {                 if (name.includes(String(num))) {                     if (injournal.includes(playerid)) {                         id=object.get('_id');                     }                 } else {                     sendChat("Downtime","/w gm A Handout with that Number does not exist!");                 }             }         });         let real=findObjs({             _type: 'handout',             _id: id         })[0];         real.get("notes",function(notes) {             log(notes);             let nnotes=notes;             if (nnotes!=="") {                 nnotes=nnotes.replace("</p>","")+description+"</p>";             } else {                 nnotes="<p>"+description+"</p>";             }             real.set("notes",nnotes);         });     }, work = function(charid,type,amount,msg) {         let skill=type;         type=type.replace("skill ","");         type=type.replace(" ","_");         type=type.replace(" ","_");         type=type.toLowerCase();         type=type+"_bonus";         amount=Number(amount.replace("time ",""));         charid=charid.replace("charid ","");         let char=findObjs({             _type: 'character',             _id: charid         }, {caseInsensitive: true})[0];         if (char) {             let attr=getAttrByName(charid,type)             var gp=0;             for (let i=0;i<Number(amount);i++) {                 gp+=randomInteger(20)+Number(attr);             }             char.get("gmnotes",function(gmnotes) {                 let time;                 time=Number(String(gmnotes.replace(" Day","")).replace("s",""));                                  if (time<amount) {                     sendChat("Downtime","/w "+msg.who+" You do not have enough time to do that!")                 } else {                     time-=amount;                     let nnotes="";                     if (time>0) {                         if (time==1) {                             nnotes=String(time)+" Day";                         } else {                             nnotes=String(time)+" Days";                         }                     }                     char.set("gmnotes",nnotes);                 }             });             var gold=findObjs({                 _type: 'attribute',                 _characterid: charid,                 _name: "gp"             }, {caseInsensitive: true})[0];             var cur=Number(gold.get('current'));             sendChat("Downtime","/w "+msg.who+" You worked for "+amount+" Days and gained "+gp+" GP!");             let mun=gp;             gp+=cur;             gold.set('current',gp);             let handnum=getHandoutNum(msg.playerid,charid);             let name = char.get("name");             let desc="<br><br>"+name+" spends "+amount+" Days working, using their "+skill+", earning "+gp+" GP.";             setHandoutDesc(msg.playerid,handnum,desc);         }     }, Can someone figure out why this is happening and how I can fix it?
1656324858
Julexar
Pro
API Scripter
Here's the entire code: GitHub Gist
1656335638
Julexar
Pro
API Scripter
Welp, somewhat fixed it, just made it create a new handout and delete the old one