
I've been developing a script recently that has some i/o with the chat. Because it is under development, it is also not yet fully user-proofed. During my testing, I just encountered two very strange situations where the chat was "leaky" in terms of letting the api run. I'm wondering if these are bugs (I will open a bug report), or if this is exactly the expected behavior. And if it is expected, I'm hoping someone can explain the rules of why it's happening so I understand better. Case 1 Input that I manually send through the chat using the tick is still invoking the api. Action : manually type into the chat input; use the tick character (`) to prepend an api call to my script
` !script_name --chat --t:@{target|Target|token_id} Expected Behavior : all of my input will get output to the chat window, nothing will be processed Actual Behavior : my input does go to the chat log (exactly as I typed it, minus the tick), but it breaks my sandbox Error : TypeError: Cannot read property 'get' of undefined
at Object.getrepeating (apiscript.js:5328:82)
at apiscript.js:5516:47... The script is expecting to process a get() statement for a token, if you include the t parameter, so it seems that the api is getting invoked but nothing is being passed to the t parameter, since the @{target} call never got processed. My token object remains undefined, and the get() fails. But it never should have been running in the first place! Case 2 This one is a little harder to explain. If in my script I read the contents of an attribute from a repeating section, and the current value of that attribute contains a roll template, and I encode the "&" character leading a roll template (replacing it with the html entity: &) and output that from the api to the chat window, the roll template itself is skipped, but an associated attribute from the set of related attributes from the repeating section is executed (the current value of that attribute is a script call). I know. Confusing. Here are a couple of visual aids... The Hero6e character sheet has a repeating section ("Powers"). repeating_ powers _{repeating element id}_... The Powers section has, among many other associated attributes, the attributes: repeating_powers_{repeating element id}_ use_power_formula repeating_powers_{repeating element id}_ extra_action An example element in this repeating section (a "power") has a roll template in the use_power_formula attribute: &{template:hero6template} {{charname=character_name}} {{power=Mountain (Strike/Shove)}} ...and a script call in the extra_action attribute: !heroll --d:check --pn:Way of the Mountain --n:does 9m of shove --t:ha --col:4b688b --tgt:__tgt__ --l:__loc__ In game, clicking on the sheet button for the power would first run the roll template (use_power_formula), then run the script call (extra_action). However, in the script I am currently developing, if I read the contents of use_power_formula into a string, then replace the leading "&" with "&" and include that in output to the chat, it doesn't process the roll template. It gives me the text as it is entered, above. It just then goes on to run the script call, too! So where I expect an output like this: I am getting an output like this: ...(which includes the resolution of the !heroll script call). It seems like there's obviously something on the character sheet that is firing the extra_action attribute if the attribute roll is used, but how is it even getting that far? If encoding the ampersand stopped the chat from processing the roll template, how does it know to fire the other attribute?