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

"Nested" Macro with roll / If statement?

October 03 (4 years ago)

Hello everyone!

I am currently trying to work on a Macro for a new campaign, which basically is supposed to improve the critical hits (and fails) instead of using the card decks. What it is suppposed to do is the following;


Character is rolling a Nat. 20 and is selecting the Macro for the crit hit. He selects which damage type it is supposed to be (slashing, piercing, fire, etc.) and the macro then rolls a 1d20. On a 1, he does the normal damage, but on every other number he gets a different additional action which the Nat. 20 caused. For example, additionally to double the damage, the creature also gets frightened or may lose a limb.


As of now I managed to get it to work up until the damage type. When I select the macro, it asks what damage type it is and then rolls a 1d20, but that#s about it. How to I code it that, depending on what the roll it, it will say what happens in the chat?


That's what I have so far;


?{Which damage type|

    Bludgeoning, ***Bludgeoning***

        You rolled a [[1d20]]. |

    Piercing, ***Piercing***

        You rolled a [[1d20]]. |

    Slashing, ***Slashing***

        You rolled a [[1d20]]. |

    Force, ***Force***

        You rolled a [[1d20]]. |

    Psychic, ***Radiant***

        You rolled a [[1d20]]. |

    Necrotic, ***Necrotic***

        You rolled a [[1d20]]. |

    Radiant, ***Radiant***

        You rolled a [[1d20]]. |

    Poison, ***Poison***

        You rolled a [[1d20]]. |

    Cold, ***Cold***

        You rolled a [[1d20]]. |

    Fire, ***Fire***

        You rolled a [[1d20]]. |

    Lightning, ***Lightning***

        You rolled a [[1d20]]. |

    Thunder, ***Thunder***

        You rolled a [[1d20]]. |

    Acid, ***Acid***

        You rolled a [[1d20]]. |

}

October 03 (4 years ago)
Oosh
Sheet Author
API Scripter

You probably want to look at Rollable Tables, so your Query options would look something like:

Lightning, ***LIghtning***

  Crit effect: [[ [1t[CritTable] ]] |


You then set up a table with your critical effects on it, and that 1t[CritTable] rolls one of the options from it. If you need the Roll Table to do further math or trigger further macros/tables, you'll probably want to look at the Recursive Tables API script.

October 04 (4 years ago)

Oh, that helped quite a lot already! :) 
I never used the Rollable Table before, completely forgot about it... :D

Now, when I roll and the result is shown, the text is highlighted in a bright yellow with bold black letters... Is it possible to change how it looks?

October 04 (4 years ago)
Oosh
Sheet Author
API Scripter

The easiest way is to use a roll template which automatically styles the text for you. From the damage type it looks like like a D&D or PF game - I think most of the relevant sheets have at least one template which will do this for you (e.g. &{template:npcaction} {{name=Rolltable}} {{description=[[ 1t[tableName]]] }} will work for the official 5e sheet).

Failing that, the API is probably your best bet since you have Pro.

This trick will also change the text, but is a bit hacky and you'd have to activate each roll with a button click after running the macro.