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 .
Advertisement Create a free account Compendium in Game, Join Today

So, these Macros then ......

1610543897
Perhaps I'm trying to do something that cannot be done here, so I'm looking to the experts for help :D I have a number of rollable tables (For random encounters whilst travelling in different locations) and a number of macros that roll on the table for example:- /w gm &{template:npcaction} {{rname= Random Encounter Table }} {{name= Random Hills/moors encounters }} {{description= [[ 1t[Random-Encounters-Hills/moors] ]] }} is the macro which rolls on the Hills/moors rollable table. What I have been trying to do (until my head started to ache!) was to create a macro that firstly gives me a selection option (of the different tables) and then calls the macro relevent to that table. Is it possible to do such a thing? I am a PLUS level subscriber.
1610545502
GiGs
Pro
Sheet Author
API Scripter
In roll20, you cant do anything conditional, like rolling on a second table based on the result of a first table. Pro level subscribers can use a script like Recursive Tables to overcome this limitation.
1610545605
This syntax would allow you to roll on tables based on a selection query, you could replace the roll call (bolded) with a call to a macro if you want to do it that way &{template:default} {{?{Choose Table | TableLabel1, [[1t[RollabaleTableName1]]] | TableLabel2, [[1t[RollabaleTableName2]]] } }}
1610551578
Ziechael
Forum Champion
Sheet Author
API Scripter
The good news is, that due to the order of operations, you can use queries within a table call itself to reduce the macro even further: /w gm &{template:npcaction} {{rname= Random Encounter Table }} {{name= Random Hills/moors encounters }} {{description= [[ 1t[Random-Encounters-?{Which Table|Hills/moors|Hills/lesses|Hills/sames|etc etc}] ]] }}
1610566442
Ziechael said: The good news is, that due to the order of operations, you can use queries within a table call itself to reduce the macro even further: /w gm &{template:npcaction} {{rname= Random Encounter Table }} {{name= Random Hills/moors encounters }} {{description= [[ 1t[Random-Encounters-?{Which Table|Hills/moors|Hills/lesses|Hills/sames|etc etc}] ]] }} That does almost EXACTLY what I wanted, Ziechael, thankyou. A further question from there, is there any way of getting the title of the table you select from the drop-down to come up in the result?
1610572844

Edited 1610637879
In a query, you can separate the parts like this: ? = start of query { } = boundary of query NAME = Name of query (What is displayed in the popup box as a prompt) SELECTION = If the query is a dropdown or has a pre-written optional answer RESULT = what the output of the macro is The NAME is always the first thing after the opening brace before a vertical pipe. SELECTIONS come after a vertical pipe. RESULTS are optional and come after a comma -- if there is no RESULT listed then the SELECTION name  is  the result. It's important to know that the output of the RESULT is everything between the comma and the vertical pipe for the next SELECTION, including any spaces.  A common error is putting a space after a comma, which can result in a space that is not intended being output before the RESULT and causing a macro not to fire. E.g.: ?{NAME|SELECTION1, RESULT1 |SELECTION2, RESULT2 |SELECTION3, RESULT3 } For this specific example, the parts in bold are what will be output, and would need to exactly match the name of the table you want to roll, such as "Random-Encounters-Hills/moors". /w gm &{template:npcaction} {{rname= Random Encounter Table }} {{name= Random Hills/moors encounters }} {{description= [[ 1t[Random-Encounters-?{Which Table|Hills & Moors, Hills/moors |Hills & Lesses, Hills/lesses |Hills & Sames, Hills/sames ] ]] }} If you reuse a query in the same macro, the output will always be the same as whatever the output from the first macro is.  Changing the inputs on a second query that has the same NAME will not do anything different.  This also means that you can reuse the output multiple times. /w gm &{template:npcaction} {{rname= Random Encounter Table }} {{name= Random Hills/moors encounters }} {{description= [[ 1t[Random-Encounters-?{Which Table|Hills & Moors,Hills/moors|Hills & Lesses,Hills/lesses|Hills & Sames,Hills/sames] ]] from table Random-Encounters-?{Which Table}}}
1610613943
Awesome, Guys, because of your invaluable help, I know have a macro that basically rolls to see if an encounter has occurred, then prompts me to choose the region the encounter is happening and rolls on the appropriate table, and then  tells me what table I have rolled on ('cause I often make mistakes :) ) /w gm &{template:npcaction} {{rname= Random Encounter Table}}{{name= Random encounters }} {{description= Encounters here occur on a roll of 16 or higher. [[ 1d20 ]] }}  /w gm &{template:npcaction} {{rname= Random Encounter Table }}{{name= Random encounters }} {{description= [[ 1t[Random-Encounters-?{Which Table|Hills/moors|Forest|Grassland|Mountains|Road/trail|Sea|Tundra}] ]] from table Random-Encounters-?{Which Table} }} Again, Guys, thanks very much for all your help!
1610638612
I might suggest a couple cosmetic changes: put the Table name in the rname or name field, and combine the dice roll into the same whisper as the table roll to consolidate the whole thing: /w gm &{template:npcaction} {{rname= Random encounters }} {{name= ?{Which Table|Hills/moors|Forest|Grassland|Mountains|Road/trail|Sea|Tundra} }} {{description= Encounters here occur on a roll of 16 or higher. [[ 1d20 ]] [[ 1t[Random-Encounters-?{Which Table}] ]] }} One other trick I like to do is use a false API call for queries, to separate them out from the body of a macro. It can help a lot with editing and troubleshooting macros: !?{Which Table|Hills/moors|Forest|Grassland|Mountains|Road/trail|Sea|Tundra} /w gm &{template:npcaction} {{rname= Random encounters }} {{name= ?{Which Table} }} {{description= Encounters here occur on a roll of 16 or higher. [[ 1d20 ]]  [[ 1t[Random-Encounters-?{Which Table}] ]] }} 
1610652991
Jarren K., thanks very much for those, certainly refined my outputs, and I'm all for a less cluttered chat area :)