So I did some very minor editing to the code Aaron edited, and for some reason that I've spent the last hour trying to figure out why it's slightly broken.
It outputs all the information into the handout perfectly, but only x updates live the others only update when I reset the sandbox. The weirder part is that all four character sheets are able to update x live, it seems x takes precedent over x when the sandbox resets but afterwards it's the most recent attribute that was modified that takes precedent.
Any help would again be very greatly appreciated!!
on("ready", function() {
const CharIDs = ['-MAhCsI9sql6KlDA6Mrz','-MAj1gtN4mNi0S8Xesbq','-MAjU5eFIGVRoBEl2mOS','-MAjTcUApOs8VZcc8ALa'];
//Fetch current wounds & strain for each character
//x,x,|y,y,|z,z,|a,a,|
let characters=findObjs({_type: 'character'});
let attributes=findObjs({_type: 'attribute'});
let formattedString="";
characters.forEach(function (chr) {
if(chr.get("inplayerjournals").split(",").length<=1){
return;
}
if(formattedString!=""){
formattedString+="|";
}
attributes.forEach(function (attr) {
if(attr.get('_characterid')==chr.get('_id')){
if(attr.get('name')=="wounds"){
formattedString+=attr.get('current')+",";
}
else if(attr.get('name')=="strain"){
formattedString+=attr.get('current')+",";
}
else{
//Do nothing, not really needed but might be good for later
}
}
});
let handout=findObjs({_type: "handout", name: "WSOutput"})[0];
handout.set("notes",formattedString);
});
on("change:attribute", function(obj) {
let curChar=getObj("character", obj.get("_characterid"));//type, unique id
let playerIDs=curChar.get("inplayerjournals").split(",");
if(playerIDs.length>1) {
//Fetch current wounds & strain for each character and save to "Char Stat Dump" handout in some formatted fashion
//x,x,|y,y,|z,z,|a,a,|
//Order fetched is always the same
let handout=findObjs({_type: "handout", name: "WSOutput"})[0];
let formattedString="";
handout.get("notes",function(notes){
let charList=notes.split("|");
if(CharIDs.includes(curChar.get("id"))){
let statList=charList[0].split(',');//wounds & strain
if(obj.get('name')=="wounds"){
statList[0]=obj.get('current');
}
if(obj.get('name')=="strain"){
statList[1]=obj.get('current');
}
charList[0]=statList.join(',');
}
formattedString=charList.join('|');
handout.set('notes',formattedString);
});
}
});
});