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

Stabilize Macro Copied Directly from Roll20 examples Fails?

1715283179

Edited 1715358707
Ao
Pro
I copied the macro for stabilize from the roll20 wiki at&nbsp; <a href="https://wiki.roll20.net/Macros/Pathfinder_Examples" rel="nofollow">https://wiki.roll20.net/Macros/Pathfinder_Examples</a> &nbsp;and it fails giving me the "TypeError: Cannot read properties of undefined (reading 'substring')" error message. Please advise and thanks! Here is the copied macro text: /me tries to convince himself the large hole in his chest is just a flesh wound... [Stabilize] DC 10 Con Check:[[ 1d20 + @{Con}[Con Mod] + @{Selected|Bar3}[Neg HP] ]] On Fail: Take [[1]] Dmg. If Neg HP([[ @{Selected|Bar3} * -1 ]]) = Con([[@{Selected|Con|Max} ]]) ...&nbsp;!! DEATH&nbsp;!!
That macro will only work if it is used as an ability on a character sheet, and will also require a token to be selected at the same time.&nbsp; @{Con} does not have a character reference (a character name or ‘selected’ or ‘target’) so Roll20 assumes that it can pull the reference from the character sheet it is located on. Since it’s not on a character sheet it fails.&nbsp; @{selected means that Roll20 will pull the information from the selected token. If no token is selected then it fails.&nbsp;
How can I revise this to work in a macro for any selected character or NPC?
If that’s the full macro, then just change @{Con} to be @{selected|Con}.&nbsp;
1715284206

Edited 1715284247
Ao
Pro
I tried that before (and after), yet still get errors: No attribute was found for @{Selected|Con} SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "S" found. Latest code:&nbsp; /me tries to convince himself the large hole in his chest is just a flesh wound... [Stabilize] DC 10 Con Check:[[ 1d20 + @{selected|Con}[Con Mod] + @{Selected|Bar1}[Neg HP] ]] On Fail: Take [[1]] Dmg. If Neg HP([[ @{Selected|Bar1} * -1 ]]) = Con([[@{Selected|Con|Max} ]]) ... !! DEATH !!
What game and character sheet are you using? If you’re not sure then please post a screenshot.&nbsp; It sounds like ‘Con’ is not a valid attribute. It may be ‘con_mod’ or ‘constitution’ or any other number of names.&nbsp;
Roll20 pathfinder sheets, revised to this: /me tries to convince himself the large hole in his chest is just a flesh wound... [Stabilize] DC 10 Con Check:[[ 1d20 + @{constitution}[constitution_mod] + @{Selected|Bar1}[Neg HP] ]] On Fail: Take [[1]] Dmg. If Neg HP([[ @{Selected|Bar1} * -1 ]]) = Con([[@{Selected|constitution|Max} ]]) ... !! DEATH !! New error message:&nbsp; TypeError: Cannot read properties of undefined (reading 'substring')
Ao said: Roll20 pathfinder sheets,&nbsp; There are 5 different Pathfinder 1st edition Sheets. /me tries to convince himself the large hole in his chest is just a flesh wound... [Stabilize] DC 10 Con Check:[[ 1d20 + @{constitution}[constitution_mod] + @{Selected|Bar1}[Neg HP] ]] On Fail: Take [[1]] Dmg. If Neg HP([[ @{Selected|Bar1} * -1 ]]) = Con([[@{Selected|constitution|Max} ]]) ... !! DEATH !! New error message:&nbsp; TypeError: Cannot read properties of undefined (reading 'substring') You still have @{constitution} instead of @{selected|constitution}.
Latest Code: /me tries to convince himself the large hole in his chest is just a flesh wound... [Stabilize] DC 10 Con Check:[[ 1d20 + @{Selected|constitution}[constitution_mod] + @{Selected|Bar1}[Neg HP] ]] On Fail: Take [[1]] Dmg. If Neg HP([[ @{Selected|Bar1} * -1 ]]) = Con([[@{Selected|constitution|Max} ]]) ... !! DEATH !! Latest Errors (now 2): No attribute was found for @{Selected|constitution} SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "S" found. Sheet is the original/default roll20 pathfinder sheet, but pic attached too
1715355649

Edited 1715355685
Gauss
Forum Champion
Hi Ao,&nbsp; Couple things I see, the DC 10 Con check should use @{selected|constitution_mod} instead of @{selected|constitution}.&nbsp; The If Neg.. line should use @{selected|constitution} there is no @{selected|constitution|max} attribute.&nbsp; So this can be cleaned up to:&nbsp; /me tries to convince himself the large hole in his chest is just a flesh wound... [Stabilize] DC 10 Con Check:[[ 1d20 + @{Selected|constitution_mod}[constitution_mod] + @{Selected|Bar1}[Neg HP] ]] On Fail: Take [[1]] Dmg. If Neg HP([[@{Selected|Bar1}*(-1) ]]) = Con([[@{Selected|constitution} ]]) ... !! DEATH !! With that, if your GM is willing there is a better way to do the last line. They'd need to make a couple of very simple Rollable Tables.&nbsp; It would just outright state if you are dead or not.&nbsp;
Thank you! It works! I found the call for Max odd, but as noted this was copied directly from roll20 pathfinder macros page, so very odd, but I am set and appreciative!
1715358777

Edited 1715359368
Ao
Pro
Does anybody know if there is a way/how to use an If-Then statement to automatically apply the 1 damage if the roll fails? (Edited to note, I do have a pro account)
1715359396
Gauss
Forum Champion
Ao said: Does anybody know if there is a way/how to use an If-Then statement to automatically apply the 1 damage if the roll fails? Macros cannot apply the damage, that is where you need a Mod (API Script). Does the GM have a Pro account?
Yes, and I have a mod script that will apply damage with, for example:&nbsp;!token-mod --set bar1_value|-1 Can that somehow be incorporated into a macro, or do I need a script to do everything I'd like here? Thanks! :)
1715360432
Gauss
Forum Champion
Yes, it can be incorporated.&nbsp; I am not able to work on it right now but I can do so later this afternoon.&nbsp;
1715360522

Edited 1715360619
Ao
Pro
Gauss said: Yes, it can be incorporated.&nbsp; I am not able to work on it right now but I can do so later this afternoon.&nbsp; You, Gauss, are an international treasure!
1715360717

Edited 1715360732
timmaugh
Forum Champion
API Scripter
Step 1: Install the Metascript Toolbox from the 1-click Step 2: Configure SelectManager by having a GM run the line: !smconfig +playerid +who Step 3: Try this command: !{{ &nbsp; /me tries to convince himself the large hole in his chest is just a flesh wound... &nbsp; [Stabilize] &nbsp; DC 10 Con Check: [[ 1d20 + @{Selected|constitution_mod}[constitution_mod] + @{Selected|Bar1}[Neg HP] ]] &nbsp; {&amp;if ${[0]] &lt; 10} &nbsp; &nbsp; Roll failed! [[1]] damage applied! &nbsp; &nbsp;&nbsp; !token-mod --set bar1_value|-1 &nbsp; {&amp;end} &nbsp; {&amp;if [[ @{Selected|Bar1}*(-1) ]] &gt;= [[@{Selected|constitution} ]] } &nbsp; &nbsp; DEATH !! &nbsp; {&amp;else} &nbsp; &nbsp; [[@{selected|constitution} + @{selected|bar1}]] HP remains. &nbsp; {&amp;end} }}
1715362698

Edited 1715363500
Ao
Pro
Thanks for this, yet it still doesn't subtract the hp from the token, just displays it. Also, doesn't display the text "Roll failed! [[1]] damage applied!" It does display the death or remaining hp notes (one further Q, but of less pertinence, could it include a way to say "Stabilized!" on a success?)
1715365663
timmaugh
Forum Champion
API Scripter
Well, check my logic (I don't know your system, so I might have gotten it wrong)... My logic for deciding whether to show or not show the "Roll failed! [[1]] damage applied!" is that the roll must be less than 10. That is, a failure would come in under the DC 10. If that is wrong, you can change the comparison (maybe greater-than-or-equal?). If you're not comfortable making the change, tell me in your own words how the conditional works (ie, "the character must roll over a 10 to avoid the point of damage") and I can help make the change. As for the "Stabilized" message, I am guessing you want it on the alternate (or "else") side of the initial Con check? So if the fails the check, you get the message about the damage point, but if it succeeds, you get the "Stabilized!" message? If that is right, then the first IF block would look more like this (note this still uses the original comparison operator of less-than, which we might still need to change): &nbsp; {&amp;if ${[0]] &lt; 10} &nbsp; &nbsp; Roll failed! [[1]] damage applied! &nbsp; &nbsp;&nbsp; !token-mod --set bar1_value|-1 &nbsp; {&amp;else} &nbsp; &nbsp; Stabilized! &nbsp; {&amp;end} Also, if possible, please screenshot the output of the message so we can better see what you're getting.
Thanks again... getting there. Yes, our game uses &lt;10 to fail stabilization, so I am not sure why the damage is not being applied and the text output from a failed roll being applied. I made slight changes to hide remaining hp from players, by whispering remaining hp. My current code follows and a screeshot showing a failure that says Stabilized (as both success and failure rolls do) to show no output from fail (or damage impact, though the&nbsp; !token-mod --set bar1_value|-1 on its own does work): !{{ &nbsp; /me tries to convince himself the large hole in his chest is just a flesh wound... &nbsp; [Stabilize] &nbsp; DC 10 Con Check: [[ 1d20 + @{Selected|constitution_mod}[constitution_mod] + @{Selected|Bar1}[Neg HP] ]] &nbsp; {&amp;if ${[0]] &lt; 10} &nbsp; &nbsp; Roll failed! [[1]] damage applied! &nbsp; &nbsp; !token-mod --set bar1_value|-1 &nbsp; &nbsp;{&amp;else} &nbsp; &nbsp; Stabilized! &nbsp; {&amp;end} &nbsp; {&amp;if [[@{Selected|Bar1}*(-1) ]] &gt;= [[@{Selected|constitution} ]] } &nbsp; &nbsp; And, with that, you have breathed your last. You have died. :( &nbsp; {&amp;else} /w gm &nbsp; &nbsp; [[@{selected|constitution} + @{selected|bar1}]] HPs remain until death. &nbsp; {&amp;end} }}
1715368953
timmaugh
Forum Champion
API Scripter
OK, my best guess is that there is another roll in your command or in one of the attributes which is occupying the 0th index (roll $[[0]]). To get around that, let's assign the roll to a variable, then reference the variable everywhere we need it. !{{ {&amp;global ([ConCheckRoll] [[ 1d20 + @{Selected|constitution_mod}[constitution_mod] + @{Selected|Bar1}[Neg HP] ]]) } &nbsp; /me tries to convince himself the large hole in his chest is just a flesh wound... &nbsp; [Stabilize] &nbsp; DC 10 Con Check: ConCheckRoll &nbsp; {&amp;if ConCheckRoll&nbsp;&lt; 10} &nbsp; &nbsp; Roll failed! [[1]] damage applied! &nbsp; &nbsp; !token-mod --set bar1_value|-1 &nbsp; {&amp;else} &nbsp; &nbsp; Stabilized! &nbsp; {&amp;end} &nbsp; {&amp;if [[@{Selected|Bar1}*(-1) ]] &gt;= [[@{Selected|constitution} ]] } &nbsp; &nbsp; And, with that, you have breathed your last. You have died. :( &nbsp; {&amp;else} /w gm &nbsp; &nbsp; [[@{selected|constitution} + @{selected|bar1}]] HPs remain until death. &nbsp; {&amp;end} }} If that still doesn't work, then add a {&amp;log} to the end of it -- right on the same line with the closing double braces, and post a screenshot of what gets output to chat as a part of the logging. =D
Beautiful! Everything works perfectly! You all have my deepest thanks! You are a star timmaugh!
1715374143
Gauss
Forum Champion
Glad timmaugh got that straightened out for you. :)