Closed mlenser closed 7 years ago
Also, if someone uses a long rest, the actual long rest output is sent to chat the next time their token comes up in the turn order. Very confusing.
I can't reproduce this, Mark. Which sheet version does that happen on?
Every single version I've used since this feature came out.
Okay I see it in console. It doesn't bomb the script, and long rest works, but there's an error. This will need some digging.
"ERROR: Did not specify an attribute name when referencing attribute using @{character_name}" "ERROR: Did not specify an attribute name when referencing attribute using @{show_character_name}"
I think this might be an interaction with a sheet worker.
This is the relevant code in the script:
this.roll20.setAttrWithWorker(char.id, attribute, !currentVal, () => {
const output = this.roll20.getAttrObjectByName(char.id, 'sheet_chat_output');
const additional = (type === 'turn') ? this.rechargeDieRollUses(char.id) : '';
this.sheetWorkerChatOutput.displaySheetChatOutput(output, null, char.id, additional);
});
And this is what "output" actually looks like:
5eShapedCompanion 1497486478840 DEBUG : Chat output received: {\"name\":\"sheet_chat_output\",\"current\":\"{{Potion of WTF recharged=5/5}} {{title=Short Rest}} {{character_name=@{character_name}}} @{show_character_name}\",\"max\":\"\",\"_id\":\"-KmcvxZnMvfplZ9RFD04\",\"_type\":\"attribute\",\"_characterid\":\"-KmcbMeaLuEPzgKeQNPn\"}"
"ERROR: Did not specify an attribute name when referencing attribute using @{character_name}"
"ERROR: Did not specify an attribute name when referencing attribute using @{show_character_name}"
What it should be is {{character_name=@{<char-id>|character_name}}} @{<char-id>|show_character_name}
I don't see anywhere in the script where that's set and the setAttrWithWorker has me thinking he's calling some of your code.
Is this a matter of needing to change what you are being sent, or is the issue purely with the worker?
SheetWorkerChatOutput.displaySheetChatOutput
is definitely part of the script.
Long rest, when pushed on the sheet, is outputting information via sheet_chat_output
which the script reads and outputs. It doesn't output any information because of this error.
Okay. This is the relevant section where it reads sheet_chat_output:
const output = this.roll20.getAttrObjectByName(char.id, 'sheet_chat_output');
And this is what it receives as a value:
{\"name\":\"sheet_chat_output\",\"current\":\"{{Potion of WTF recharged=5/5}} {{title=Long Rest}} {{character_name=@{character_name}}} @{show_character_name}\",\"max\":\"\",\"_id\":\"-KmcvxZnMvfplZ9RFD04\",\"_type\":\"attribute\",\"_characterid\":\"-KmcbMeaLuEPzgKeQNPn\"}"
The attributes without ID is what's throwing the script. character_name and show_character_name don't have ID in front of them.
Is this as designed? Should the script add the ID here? Or do I expect the sheet to pass something over that reads @{<id>|character_name}
?
I'm unsure how Lucian intended it. I'll have to take a look to see how much access I have to character id at the point where I generate these messages. How difficult do you think it is to insert the id on the script side? I expect it'd be a replace, possibly using regex, but complicated by the fact that you have to detect if an id is already present.
Important remark: @{\<char-id>|attribute name} does not actually work in chat currently. You either have to use the char name instead, or (probably better) use getAttrByName in the API to replace @{something} with getAttrByName(char.id, 'something').
use getAttrByName in the API to replace @{something} with getAttrByName(char.id, 'something').
That sounds the most promising.
Thanks that's useful. Character name, then, not charid. I have a regex that can pull the attribute out and will not touch it if a character name is present. If I'll add the character name it'd be this:
(@{)(?!.*?\|)(.*?)}
And if replacing the entire attribute string with the attribute value, then this:
(@{(?!.*?\|)(.*?)})
I think this only bombed with "Character Name on all roll templates", but I'm not entirely certain.
Regardless, this has been fixed. Will be in 11.1.0.
Character name is always sent, only shown when that setting is true, so it should've broken for every case.
Thanks for fixing it! :)
Resolved as part of 11.0.0
When I long rest the output seems to generate a script error:
"5eShapedCompanion 1495273129208 ERROR : TypeError: Cannot read property 'get' of undefined\n at Reporter.sendCharacter (apiscript.js:1886:32)\n at SheetWorkerChatOutput.displaySheetChatOutput (apiscript.js:8765:22)\n at handlerWrapper (apiscript.js:7319:33)\n at forEach.handler (apiscript.js:7235:82)\n at Array.forEach (native)\n at EventDispatcher.roll20.on (apiscript.js:7235:63)\n at eval (eval at (/home/node/d20-api-server/api.js:146:1), :65:16)\n at Object.publish (eval at (/home/node/d20-api-server/api.js:146:1), :70:8)\n at TrackedObj.set (/home/node/d20-api-server/api.js:909:14)\n at updateLocalCache (/home/node/d20-api-server/api.js:1194:18)"