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

Problem of macro advanced usage

1564644080
Sad
Sheet Author
API Scripter
Hi,  i am writing a Roll Queries macro. But it can't work well. What is the problem....? I have read the wiki and change the code.   ?{防禦類型|     基礎防禦,&{template:pc} @{target|defense_01_bonus_sum} @{target|defense_01_sum}?{調整值|0}{{name=@{atkname}}} {{Addon00=[[@{atk_DP_sum}]] }}{{Addon01=@{target|defense_01_base} –@{defense_01_other01} }}    {{Addon02=[[@{target|defense_01_condition_01}+@{target|defense_01_condition_02}]] –@{atk_addon_01} }} {{Addon03=[[@{target|defense_01_condition_03}+@{target|defense_01_condition_04}+@{target|defense_01_condition_05}]] –@{atk_addon_03} }}{{Addon04=[[@{target|defense_01_condition_06}+@{target|defense_01_condition_07}]] –@{atk_addon_04}}} {{change=?{調整值|0}}}{{limit=(@{atk_limit_sum})}}{{結果}}{{notes=@{atk_notes}}}{{atkdesc=@{atkdesc}}}{{roll=[[[[{ [[[[@{atk_DP_sum}]]-[[{[[@{target|defense_01_sum}  -@{atk_addon_02}  ]],[[0]]}kh1]]-[[{[[[[@{target|defense_01_condition_01}+@{target|defense_01_condition_02}]] -@{atk_addon_01}  ]],[[0]]}kh1]] -[[{[[[[@{target|defense_01_condition_03}+@{target|defense_01_condition_04}+@{target|defense_01_condition_05}]] -@{atk_addon_03}  ]],[[0]]}kh1]]+[[?{調整值|0}]] -[[{[[[[@{target|defense_01_condition_06}+@{target|defense_01_condition_07}]] -@{atk_addon_04}  ]],[[0]]}kh1]] ]],[[0]]}kh1]]d10>8!@{atk_again}]]}}{{atk_bonus_used2=[[[[@{atk_bonus_used_amount}]] - [[@{target|defense_01_bonus_sum}]]]]}}|      全力防禦, **Cure Moderate Wounds** Target Regains [[2d8+8]] HP. |      肉搏格擋, **Cure Serious Wounds** Target Regains [[3d8+8]] HP.|     白刃格擋, **Cure Moderate Wounds** Target Regains [[2d8+8]] HP. |      措手不及, **Cure Moderate Wounds** Target Regains [[2d8+8]] HP. |      自定防禦, **Cure Moderate Wounds** Target Regains [[2d8+8]] HP.  } After change ?{防禦類型| 基礎防禦,&{template:pc} @{target|defense_01_bonus_sum} @{target|defense_01_sum}?{調整值|0}{{name=@{atkname}}} {{Addon00=[[@{atk_DP_sum}]] }}{{Addon01=@{target|defense_01_base} –@{defense_01_other01} }} {{Addon02=[[@{target|defense_01_condition_01}+@{target|defense_01_condition_02}]] –@{atk_addon_01} }} {{Addon03=[[@{target|defense_01_condition_03}+@{target|defense_01_condition_04}+@{target|defense_01_condition_05}]] –@{atk_addon_03} }}{{Addon04=[[@{target|defense_01_condition_06}+@{target|defense_01_condition_07}]] –@{atk_addon_04}}} {{change=?{調整值|0}}}{{limit=(@{atk_limit_sum})}}{{結果}}{{notes=@{atk_notes}}}{{atkdesc=@{atkdesc}}}{{roll=[[[[{ [[[[@{atk_DP_sum}]]-[[{[[@{target|defense_01_sum} -@{atk_addon_02} ]],[[0]]}kh1]]-[[{[[[[@{target|defense_01_condition_01}+@{target|defense_01_condition_02}]] -@{atk_addon_01} ]],[[0]]}kh1]] -[[{[[[[@{target|defense_01_condition_03}+@{target|defense_01_condition_04}+@{target|defense_01_condition_05}]] -@{atk_addon_03} ]],[[0]]}kh1]]+[[?{調整值|0}]] -[[{[[[[@{target|defense_01_condition_06}+@{target|defense_01_condition_07}]] -@{atk_addon_04} ]],[[0]]}kh1]] ]],[[0]]}kh1]]d10>8!@{atk_again}]]}}{{atk_bonus_used2=[[[[@{atk_bonus_used_amount}]] - [[@{target|defense_01_bonus_sum}]]]]}}| 全力防禦, **Cure Moderate Wounds** Target Regains [[2d8+8]] HP. | 肉搏格擋, **Cure Serious Wounds** Target Regains [[3d8+8]] HP.| 白刃格擋, **Cure Moderate Wounds** Target Regains [[2d8+8]] HP. | 措手不及, **Cure Moderate Wounds** Target Regains [[2d8+8]] HP. | 自定防禦, **Cure Moderate Wounds** Target Regains [[2d8+8]] HP. }
1564645299
GiGs
Pro
Sheet Author
API Scripter
You cant use html replacements within attribute or ability calls. This, for instance [[@{atk_DP_sum}]] will always fail. The wiki explains this, but it needs to make it clearer, because it's the most common mistake. When roll20 processes your macro, it does things in a specific order. First it looks through the entire macro, looks for any attribute and ability calls, and replaces them in the macro with their values. A later step is to look through the entire macro, and replace html entities with their characters. So, when looking for attributes, this: @{atk_DP_sum} isn't recognised as an attribute, because it should be @{atk_DP_sum} and so the macro fails. So, to get your dropdown to work you need to be very careful about which characters to replace, and only replace the ones that are needed. Never, ever change abilities or attributes. Personally I never use complex dropdowns any more, I use chat menus (see the stupid tricks thread). They are so much  easier to make. 
1564651943
Sad
Sheet Author
API Scripter
GiGs said: You cant use html replacements within attribute or ability calls. This, for instance [[@{atk_DP_sum}]] will always fail. The wiki explains this, but it needs to make it clearer, because it's the most common mistake. When roll20 processes your macro, it does things in a specific order. First it looks through the entire macro, looks for any attribute and ability calls, and replaces them in the macro with their values. A later step is to look through the entire macro, and replace html entities with their characters. So, when looking for attributes, this: @{atk_DP_sum} isn't recognised as an attribute, because it should be @{atk_DP_sum} and so the macro fails. So, to get your dropdown to work you need to be very careful about which characters to replace, and only replace the ones that are needed. Never, ever change abilities or attributes. Personally I never use complex dropdowns any more, I use chat menus (see the stupid tricks thread). They are so much  easier to make.  Thank you for your help, chat menus is a good idea. I will try it. But about dropdowns, now i have a new problem I try the simple code to test dropdowns. If i input the first one in chatroom,  it will work fine. But it will fail when i put in the character sheet button...... ?{Name of Query|Defense,&{template:default}{{name=test}}{{abc=[[@{selected|defense_01_bonus_sum}]]}}{{change=?{change |0}}} {{roll=[[{4d6,3d8}kh1]]}}|Label 2, ?{value2|value2}} <button class='new-roll' title="auto cal" type='roll' value='?{Name of Query|Defense,&{template:default}{{name=test}}{{abc=[[@{selected|defense_01_bonus_sum}]]}}{{change=?{change |0}}} {{roll=[[{4d6,3d8}kh1]]}}|Label 2, ?{value2|value2}}' name='roll_attack2_style' />