I virtually never want my players to see the attack descriptions
for monsters, so I want to change the Show/Hide Description for NPC attacks. Instead of modifying each monster/attack
manually, I’d like to use either using an existing script or write my own. If it makes a difference, I have not switched this game over
to Jumpgate. It’s relatively close to
the end and I'm waiting for the next campaign. I would switch to Jumpgate if
that would help anything. I am also using the D&D 5E 2014 By Roll20 character sheet.
I started out trying ChatSetAttr, but ran into an
issue. When I issue the following
command in the chat, the option menu changes to Show, but the attack description
itself (not just the option menu) also changes to the string “show”. !setattr --sel --repeating_npcaction_$1_show_desc|show So when I make the attack and roll the damage, the attack description
is now simply the word “show”. When I issue a similar command with hide instead of show,
the option menu does NOT change to Hide, but the attack description changes to
the string “hide”. The descriptive text (now
just the word “hide”) still appears when I roll the damage. So I decided to try my own script. In the interest of full disclosure, my
javascript is poor – it looks just like my C++ (which is pretty decent). But I don’t think that’s my problem. Using getAttrByName() I am able to get at attributes like repeating_npcaction_$1_name
and repeating_npcaction_$1_show_desc.
The latter returns “@{description}” which is what I see when I inspect
the html.
In order to change the values I tried using findObjs(). As a test, I tried the following to get and
set the strength attribute: var strengthAttr = findObjs({ type: "attribute", characterid: characterId, name: "strength" })[0]; if (strengthAttr) { var strengthValue = strengthAttr.get("current"); log("Strength is: " + strengthValue); } strengthAttr.set("current", 25); This all worked fine, and I was able to modify the strength
to 25. When I try doing something similar for repeating_npcaction_$1_show_desc,
I get an undefined returned. let secondActionAttr = findObjs({ type: "attribute", characterid: characterId, name: "repeating_npcaction_$1_show_desc" })[0]; log("secondActionAttr is: " + secondActionAttr); This prints undefined. I’ve tried using repeating_npcaction_$1_name (which I can also
get via getAttrByName) but I also get undefined.
When I inspect the html for the option menu I see: <select name="attr_show_desc"> <option value="@{description}" data-i18n="show">Show</option> <option value=" " data-i18n="hide">Hide</option> </select> The Show option always has the “@description” even if the
option menu is currently set to Hide. All of this leads me to believe I don’t know what I’m doing,
although I suspected that all along. So my question is in two parts. (1) Am I using ChatSetAttr incorrectly? (2) In my script, how can I get the object for the Show/Hide
option menu and set it to what I want? Even if someone can tell me what I’m doing wrong with
ChatSetAttr, I’d still appreciate it if anyone could tell me what is wrong with my own script code. Thanks. -- John