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

Macro: variable text output.

December 31 (3 years ago)

I'm sure this is basic stuff.  Just trying to learn.

Can a macro output a specific text, dependent on a range of the dice roll?

Example:

[[1d100]]

0-50 output "text 1"

51-100 output "text 2"


Thanks

December 31 (3 years ago)
David M.
Pro
API Scripter

The easiest way is to create a rollable table with text "items" that are given the appropriate weight. You can "roll" on that table using [[ 1t[tableName] ]] syntax.

December 31 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

A rollable table will do this for you, if you don't need any modifiers.

If you need to work off of a formula ([[1d100 + @{some_modifier}]], I believe the API Script Cards can do this for you. There are probably other solutions available through the API.

In general though, regular macros are simple dice and reporting formulas, and lack scripting features such as looping or branching.

December 31 (3 years ago)

Edited December 31 (3 years ago)

Yes I considered that.  Its NPC specific so for the sake of keeping the collections tab from having tables that are rarely used I thought maybe including it with in the NPC template would be more prudent.

I created a NPC template and the NPC is 50% neutral good or 50% neutral evil.

I created a trait called Variable: Neutral Alignment

In the text explanation I added [[1D100]]

It displays all the trait information and the outcome of the roll when I select the Token Trait Button.  (Set up from "Monster Templates" video)

I thought I would try and take it to the next level by outputting "Neutral Good" or "Neutral Evil" rather than the actual dice roll.

December 31 (3 years ago)
timmaugh
Forum Champion
API Scripter

If you don't mind storing the source data on the NPC sheet (so it doesn't clutter the collection tab), you can use Muler ... OR ... this might the simpler ... Apply a success threshold to your roll, then have an attribute for a 0 (Neutral Good) and for 1 (Neutral Evil). Finally, use Fetch to return the value, since it will return the value after the roll.

@(Source Character.[[1d100>50]].value)

You can use that in any macro (provided you start as an API call -- can be changed midway through).

To make it work you'll need Fetch and ZeroFrame.