
Hi all,
I got an issue regarding the scripting using character attributes, which are using a formula to be computed. Let's be a little bit more precise.
I am using the "The Witcher TRPG" character sheets and I want to access the current stats and skills, e.g. the current stat for "Reflexes". The attribute in the character sheet is "ref" but the value is no number but the following formula:
[[((floor((@{total_ref}+@{stat_mod_ref})@{wound_mod})+1)+abs((floor((@{total_ref}+@{stat_mod_ref})@{wound_mod}))-1))/2]]
I am able to get exactly this formula extracted from a currently selected token, which represents a character sheet:
on('ready',function(){
"use strict";
on("chat:message", function(msg) {
let targetID, selectedCharacterRef;
// Check if we have an api message including the command !test
if(msg.type == "api" && msg.content.indexOf("!test") !== -1) {
let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname');
// parse arguments into a hierarchy of objects
let args = msg.content.split(/\s+--/).map(arg=>{
let cmds = arg.split(/\s+/);
return {
cmd: cmds.shift().toLowerCase(),
params: cmds
};
});
let selected = args.find(c=>'selected' === c.cmd);
let target = args.find(c=>'target' === c.cmd);
if(target){
targetID = target.params[0];
}
if(selected){
selectedCharacterRef = getAttrByName(selected.params[0],'ref');
if(selectedCharacterRef)
{
sendChat("Success", "Test");
log(selectedCharacterRef);
sendChat("API",selectedCharacterRef);
//"[[((floor((@{total_ref}+@{stat_mod_ref})@{wound_mod})+1)+abs((floor((@{total_ref}+@{stat_mod_ref})@{wound_mod}))-1))/2]]"
}
else
{
sendChat("Fail","No selected character found");
}
}
}
});
});
The error occures at the line "sendChat("API",selectedCharacterRef);" throwing an exception:
For reference, the error message generated was: SyntaxError: Expected "[" but "o" found.
undefined
Apparently, I am missing something or I am running into some kind of bug? Every advise is gladly welcome!
If anyone needs more information please let me know.
Best regards and thanks in advance!