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

Nesting Macros and Recursive Tables

February 04 (4 years ago)

Ok, I have about 20 hours of research crawling around the Forums over the last few days and i Hit a wall i cannot get past.

I created a table named 'TableName'. I got it to kick back as i wanted. YAY!

I created a macro named MacroName1 to call the Table, Then in a template, Then a whispered Template. Then i stole some nicer code from a forum post. They All work, YAY!

PROBLEM:

Now for the Buttons on the nested Macros. As Pictured Above, Macro 1 and 3 Kick back some kind of error(#MacroName1) , But Macro 2 Will roll Perfectly, But without a Template. What do i need to change to get a template? And can i create a button that rolls on a table a settable number of times?

Because im New, Im trying to create a template that i can call back on.


February 04 (4 years ago)

Edited February 04 (4 years ago)
Jordan C.
Pro
API Scripter

I am not sure I see/understand where the error for 1 and 3 are as they seem to be correctly outputting the macro. The text "#MacroName1" showing up in chat happens when exactly? That usually happens when the game can't find a macro with that name or the hash was escaped and I don't see either of those being the issue. I also don't see the issue with 3 kicking back an error at all so if you can be more specific there that might help.

If you want to set a custom number of rolls from the table each time you press it you can use this macro

!rt[Delimiter:BR] /w gm [[ ?{How Many Rolls?|0}t[TableName] ]]

In a template it would look like this

!rt[Delimiter:BR] /w gm &{template:default} {{name=Results}} {{Treasure=[[ ?{How Many Rolls?|0}t[TableName] ]] }}

February 04 (4 years ago)

I tested for a while, apparrently, My computer got off its luch break or something brecause it just returned popperly on everything.... I have no clue why. Maybe my Bad internet connection is not sending the code properly? Thank you for you help. I will post the basic code for the next person to come along and save them the aggony of learning through Forums.

February 04 (4 years ago)

Edited February 07 (4 years ago)


Step 1. Get the RecursiveTables API by The Arron. I learned all this by reading through the last 5 years of forum posts by him. He's awesome, and I'd Chip him a $20 for all the learning I got.

Step 2. Create a table named TableName. Add an item that has a dice roll for testing. The dice will not roll if you press the roll button.

Step 3. Create a Macro named MacroName1. in the box place one of the following codes

This Code just Whispers into Chat: !rt /w gm [[1t[TableName] ]]

This code whispers and creates a template into chat: !rt /w gm &{template:default}{{treasure=[[1t[TableName]]]}}

Step 4. Create a Nesting Macro That has buttons to call other Macros: 
/w gm &{template:default} {{name=Nesting Macros}} {{[Macro1](!
#MacroName1 ​), [Macro2](!
#MacroName2 ​), [Macro3](!
#MacroName3 ​)}}

After you get all that to work, Get the Export tables API, And learn how to use that. Github has a bunch of importable tables ready to go.

Edit 2: After further testing, I found a WAY easier way to do this. Create a handout and link words in the handout to macros. Type in a word, click the hyperlink button, or cntl+K. and type in the URL: `#MacroName. If you try to copy and paste hyperlinked words from a document, they break.