I'm getting a really weird error on a function I am working on. I've put lots of logs in there to try to track it down. This function should take the notes section from one handout and make a new handout with the same notes section. The notes section is long, so I've abbreviated it in this code on('chat:message', (msg) => {
if ('api' === msg.type && /!test\b/i.test(msg.content)) {
const args = msg.content.split(/\s+--/);
log('start test');
let handout = findObjs({
_type: "handout",
name: "README"
})[0];
//log(handout);
let text = 'nothing';
handout.get("notes", function(notes) {
//log(notes); //do something with the character bio here.
text = notes;
});
log('after handout.get');
createObj("handout", {
name: "README ALSO",
inplayerjournals: "all"
});
log('after createObj');
let newhandout = findObjs({
_type: "handout",
name: "README ALSO"
})[0];
log('after newhandout');
log(text);
newhandout.set({notes: text});
log('after set');
}
}); Here is the console logs it produces: "start test" "after handout.get" "after createObj" "after handout.get" "after newhandout" "<p>Skall! Welcome to the Fate of the Norns Companion Script. This script will enhance the ... and then re-check the runes under actives.&nbsp;</p>" "after createObj" "after newhandout" "nothing" "after set" "after set" This run produced two handouts, one with "nothing" in the notes area and one with the "<p>Skall..." text. It doesn't always do this, sometimes it produces one handout with "nothing", sometimes it produces one handout with "<p>Skall...". This is the first run where I put in all of the logs to track the flow of the script. I am stumped. I've tried it with var instead of let and its still wonky.