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 .
×

Nested macro which works fine in the game does not work as a part o character sheet

Hi all, I have the following nesting macro which works fine when I used it in the game as ability macro for character. But if I place it in the Character sheet as macro for button it does not work. Here is a macro (I added some linebreaks for better understanding) - &{template:default} {{name=**Armor damage absorption** }} {{Description=**@{character_name}** got hit in his armor!}} {{Incoming Damage= [[ (?{Damage Received|0} [DMG] ) ]]}} {{Received DMG/Type=     ?{Damage Type         |Normal, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_normal})*(1-([[ @{damage_resistance_normal}]]/100) )) + 0d0]]),0}d1]] / **Normal**         |Laser, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_laser})*(1-([[ @{damage_resistance_laser} ]]/100) )) + 0d0]]),0}d1]] / **Laser**         |Plasma, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_plasma})*(1-([[ @{damage_resistance_plasma} ]]/100) )) + 0d0]]),0}d1]] / **Plasma**         |Explosion, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_explosion})*(1-([[ @{damage_resistance_explosion} ]]/100) )) + 0d0]]),0}d1]] / **Explosion**         |Fire, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_fire})*(1-([[ @{damage_resistance_fire} ]]/100) )) + 0d0]]),0}d1]] / **Fire**         |Radiation, [[floor( (?{Damage Received|0} [DMG] )*(1-([[ @{resistance_radiation} ]]/100) )) ]] / **Radiation**         |Poison, [[floor( (?{Damage Received|0} [DMG] )*(1-([[ @{resistance_poison} ]]/100) )) ]] / **Poison**         |Gas, [[floor( (?{Damage Received|0} [DMG] )*(1-([[ @{resistance_gas} ]]/100) )) ]] / **Gas**         |Electricity, [[floor( (?{Damage Received|0} [DMG] )*(1-([[ @{resistance_electricity} ]]/100) )) ]] / **Electricity**     } }} Macro as  a sheet button with result Macro as ability Any ideas why it does not work? It seems that the error is here in first choice  (?{Damage Received|0} [DMG] ).
1585680605
Kraynic
Pro
Sheet Author
What happens if you strip out all the html replacements and just use the normal characters (closing curly brackets and such) in the roll button code?
The same result as on the screenshot - macro does not work.
1585689010
Kraynic
Pro
Sheet Author
Does it work with any options beyond the first if you add them one at a time? 
Pretty good from ability macro. I think maybe I will try to split the macro using hidden sheet attributes to remove nesting queries, since if they are not present all works fine.
I ran some tests now with both splitted macroses and solid ones and it seems that following construction does not work in Character Sheet HTML. ?{Some words|Label_1, ?{Some words again|0}|Label_2, value_2} The inner option section never gets resolved if you place it.
1585706507
GiGs
Pro
Sheet Author
API Scripter
You';d need html replacements on the inner queries | and } for that to work.
I tried with html replacements, still not work.
1585729768
GiGs
Pro
Sheet Author
API Scripter
What was the specific code you tried?
1585730142
GiGs
Pro
Sheet Author
API Scripter
Interesting, you're right, this doesnt seem to work. I tried this <button type="roll" name="roll_test" value="?{Some words|Label_1, ?{Some words again|0}|Label_2, value_2}"></button> and it failed. The drop down showed the first item, and the second item showed 0. When I selected the first item, the second items text (Label_2, value_2) was printed to chat. So whatever processing is done on character sheet roll button output breaks html entities.
1585734572

Edited 1585736382
Ziechael
Forum Champion
Sheet Author
API Scripter
Double nesting the html seems to work: <button type="roll" name="roll_test" value="?{Some words|Label_1, ?{Some words again|0}|Label_2, value_2}"></button> This would suggest that the button parses the html when run which then breaks the nested element, increasing the nesting required by one each time should resolve it. Hmm, a triple nest doesn't seem to want to work: <button type="roll" name="roll_test" value="?{Some words|Label_1, ?{Some words again|?{yet more words|0}}|Label_2, value_2}"></button>
1585735408
GiGs
Pro
Sheet Author
API Scripter
I tried double nesting too, thinking the same but it didnt work. I have a feeling some processing is being done to forcibly remove html entities for security purposes.
I think I've figured out why it didn't work using these 2 examples. If we compare GiGs' code to Ziechael's  - Ziechael used HTML code symbol for "&" sign too so "|" symbol is not represented as "|" (as in GiGs' macro) but as "|"/. I 've replaced "&" signs in my macro using the same logic - and it actually works! So now it is like this -   &{template:default} {{name=**Armor damage absorption** }} {{Description=**@{character_name}** got hit in his armor!}} {{Incoming Damage= [[ (?{Damage Received|0} [DMG] ) ]]}} {{Received DMG/Type= ?{Damage Type |Normal, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_normal})*(1-([[ @{damage_resistance_normal}]]/100) )) + 0d0]]),0}d1]] / **Normal** |Laser, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_laser})*(1-([[ @{damage_resistance_laser} ]]/100) )) + 0d0]]),0}d1]] / **Laser** |Plasma, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_plasma})*(1-([[ @{damage_resistance_plasma} ]]/100) )) + 0d0]]),0}d1]] / **Plasma** |Explosion, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_explosion})*(1-([[ @{damage_resistance_explosion} ]]/100) )) + 0d0]]),0}d1]] / **Explosion** |Fire, [[{([[ floor(( (?{Damage Received|0} [DMG] ) - @{damage_threshold_fire})*(1-([[ @{damage_resistance_fire} ]]/100) )) + 0d0]]),0}d1]] / **Fire** |Radiation, [[floor( (?{Damage Received|0} [DMG] )*(1-([[ @{resistance_radiation} ]]/100) )) ]] / **Radiation** |Poison, [[floor( (?{Damage Received|0} [DMG] )*(1-([[ @{resistance_poison} ]]/100) )) ]] / **Poison** |Gas, [[floor( (?{Damage Received|0} [DMG] )*(1-([[ @{resistance_gas} ]]/100) )) ]] / **Gas** |Electricity, [[floor( (?{Damage Received|0} [DMG] )*(1-([[ @{resistance_electricity} ]]/100) )) ]] / **Electricity** } }} Big thanks to both of you)
1585744250
Ziechael
Forum Champion
Sheet Author
API Scripter
Glad I could help, from what I can tell you won't be able to leverage any further levels of nesting but  if what you have now works and is the extent of it then we can all call this a win :) Happy rolling!