Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Need Help: msg objects from chat event not working && MonsterHitDice && DeathTracker

1582479462

Edited 1582480303
Preface, I'm familiar with Java but I'm new to JS and it's been a slow struggle learning by examining other people's code. I've been at it a week(end) and these questions are the result of my limited knowledge: I'm trying to generate hitpoint (HP) values on tokens dropped on the table from the journal, producing disposable tokens that are representative of generic monster encounters. (I'm trying to display on bar3 - cuz of the lovely red color!)  1. If anyone can help me format  MonsterHitDice  to the the  ACKS character sheet  - "MBhitdice" - we can skip this entire problem and have a nice drink.  I'm sure it would also avoid the issue with  DeathTracker  instantly killing things I drop on the table with my bootleg HP generator.    2. [If you've got a solution to #1, you can skip this or just read hear about my struggles] Since I can't get  MonsterHitDice  to work, and don't need all the robustness of the full code, I was trying to make my own HP generator. Everything is working except the math for the dice roll. I initially set my return value to the HD string to ensure I was properly retrieving the data and narrowed the issues to the dice math. For this monster ( type Character ) - "Horse, Medium" - the HD is 3d8. There might be some redundancies in the code because I was trying to ensure the HD value being manipulated was a String .              a. the processInlinerolls(msg) function provided only works on input of type msg retrieved from a chat event. All of the code within the call event is  only applicable to a defined object of type msg . So it's not at all useful to me because the hitdice (HD) value (in full dice notation) is already stored as an attribute of Character object generated by the character sheet.  Essential/Special NPCs are directly prompted for HP by the character sheet, while monsters have a recorded "MBhitdice" reflecting the HD. (Plus I have no idea what the return type of msg.content is.)             b. the next solution to the problem was to send the HD value to chat then retrieving it to do the processInlinerolls(msg) function. But the function did absolutely nothing and the returned result was the HD (still in dice notation).                              ==(on token drop)==>              c. I figured that I just wasn't familiar enough with the parameters and tried to have the QuantumRoller do the math by sending the full roll command to chat, then just returning the result.  Same result: bar was set to "3d8/3d8"                                          d. I thought that maybe the full message wasn't being sent to chat properly but that wasn't the case.                    ======>              e. So with the issue being isolated to the callback, I assumed that I was just confused about the input and return types for all these functions. I tried: using _.reduce(x) to condense the ops  array into a single number  (inferred from examples) value   ==> got an error about the iteree so I'm assuming the _.reduce() function only works on arrays of primitives?? using String( ops [0]) to convert the result into a String object ; when that didn't work I tried figuring out ToPrimative(x) to turn the String object and ops [0] into primitive strings   using parseFloat(obj[0]) and parseInt(obj[0]) ==> the result of these were "NaN" I'm obviously grasping at straws and the only thing I haven't tried yet is trying to turn the value retrieved from the callback into a String  then into a number .  Question: Can someone please tell me what I'm doing wrong? 3. [If you've got a solution to #1 or #2, you can skip this or just read further for my to hear about Day 3 of my struggles] I tried just importing a dice roller from a very generous soul who posted his script online: rpg-dice-roller .  Since I'm Mr. Noob - first name Super - I tried looking into how to do that. My brain railroaded me on the "import" part of "import the fully-functional code!"              a. using the provided import code didn't work. Instead, I just got the API Output Console asking me why a random bracket is floating around  ==(on token drop)==>             b. I tried just copying the code and making it a stand-alone script in my API library - easy! But couldn't figure out how to use functions in the RPGDiceRoller script - to make a new roller - in my script. I tried looking at other people's code to figure it out but people usually leave comments at the level of a function and my eyes swam trying to figure out what *custom* function was being called from *another* script unique to that person's API library, not just a function already inherent to the JS language or the Roll20 platform.   Question: Help? 4. [Related to the DeathTracker script] Whenever I place a token onto the map and have its HP set (at this point I'm stating a value to set it to), the DeathTracker immediately kills it and the Lazy Experience script offers up its xp. Great that they're working in tandem, but why are they triggering? There is no red tint, indicative that the monster( token ) took any damage. I tried deactivating HP generation functions, setting bar values, then slowly decreasing them to 0.  Everything worked as it should, then. I thought the sequence of set commands mattered (in case the changes were being tracked constantly) so changed syntax a bunch. Original:   (changed to test setting bar values) Test1:  ==(on token drop)==>  +  (double message) Test2:   ==(on token drop) ==>  +   (double message) Test3:   ==(on token drop)==>  +   (double message, again) Test4:  ==(on token drop) ==>   +  (triple message) Question: What am I doing that makes the DeathTracker kill my token immediately after I give it HP? For reference, this is normal progression:  =>   =>   =>   => 
I resolved the issue by altering code in the scripts:  MDHitDice defaults and code were altered to account for the custom character sheet and DeathTracker now doesn't do anything if a maxHP value isn't set