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

Need help with complex macro nesting

1508791039
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I'd like to create a menu of NPCs, usable by myself or players. I'd like to be able to run the macro and have a roll-template-formatted menu of clickable links, with the name of each NPC being a link. Clicking on the name would call up a picture of the NPC, a sentence or so of public knowledge and a sentence or so of GM-only knowledge. I'd like to avoid having character sheets for these folks, these are guildmasters, sages, barkeepers, alchemists and the like. I know how to get a web-based image to display: [Name](URL) I know how to make an API Command button: [Name](!Some_Command) I know how to make an ability command button [Name](~<keyword>|<ability name>) or [Name](~<ability name>) I can get any one of these to work, but I'd like something like: [Name](Image Url displayed in chat info about person /w gm secret info about person) Preferably done as a list of buttons within a single macro all wrapped up nice in a roll template. I have tried endless permutations of code, and thrown in some random HTML element replacements, but can't get it to do what I want. Does this even sound possible?
1508791459

Edited 1508791483
The Aaron
Pro
API Scripter
Try: [Name](!
[x](Image Url displayed in chat)
info about person
/w gm secret info about person)
1508792495
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That's pretty close to something I tried earlier. It returns: Name info about person /w gm secret info about person)
1508792498
Silvyre
Forum Champion
Nesting an image is tricky business, mostly because of colons : [Name](!/&amp;#13;[Image](<a href="https://app.roll20.net/v2/images/roll20-logo.png&amp;#41" rel="nofollow">https://app.roll20.net/v2/images/roll20-logo.png&amp;#41</a>; &amp;#13;Roll20 &amp;#13;/w gm is run by lizard people)
1508792768
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
This is what I posted, with url in place, just in case I've screwed up some syntax by putting it in there: [Name](!&#13;&lbrack;x&rbrack;(<a href="https://i.imgur.com/Ah3mSIk.png)&#13;info" rel="nofollow">https://i.imgur.com/Ah3mSIk.png)&#13;info</a> about person&#13;/w gm secret info about person) The image is just some random google search image for now.
1508792970
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Silvyre said: Nesting an image is tricky business, mostly because of colons : [Name](!/&#13;[Image](<a href="https://app.roll20.net/v2/images/roll20-logo.png" rel="nofollow">https://app.roll20.net/v2/images/roll20-logo.png</a>&#41; &#13;Roll20 &#13;/w gm is run by lizard people) Ding-ding-ding! That's a winner! Thanks guys! Now to set this up in a macro code generating spreadsheet and start making NPCs.
1508793081
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It even works nicely in a roll template. Even though the final output is vanilla chat, this does what I need it to do.&nbsp;
1508794953
Silvyre
Forum Champion
Cheers!
1508796168
The Aaron
Pro
API Scripter
Shucks, missed one closing parenthesis to escape!&nbsp; I demand partial credit!!!!&nbsp; =D&nbsp;
1508800151
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I will break this imaginary cookie exactly down the center and give you each half. Thanks again. :)
1508800385
The Aaron
Pro
API Scripter
HAHAHAHAH!
1508985413
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I've been playing with this for a few days now, and so far I'm very much liking the results. I've tweaked the code a little give more info so that this: /w gm &{template:5e-shaped} {{title=High Harbor Folk}} {{text_big=These are general people to be found in High Harbor [Aurelius](!/&#13;[Image](<a href="https://i.imgur.com/tkZBeDp.jpg" rel="nofollow">https://i.imgur.com/tkZBeDp.jpg</a>&#41; &#13;** Aurelius — **Golden Dragonborn. High level Wizard with eye for business. Has carnivorous plant companion.&#13;/w gm Knows identity of Selendriana) - *Dragonborn Wizard* [Arabella](!/&#13;[Image](<a href="https://i.imgur.com/ZSSMI0m.jpg" rel="nofollow">https://i.imgur.com/ZSSMI0m.jpg</a>&#41; &#13;** Arabella — **Carnivorous plant companion of Aurelius. Cannot speak, but can understand common.&#13;/w gm Cannot speak, but can understand common.) - *His Carnivorous Plant Companion* }} produces this: Clicking on "Aurelius" in the example above gives me this: This is beautiful, but I'd like to extend the functionality. I have a separate block of code for each area of town or major group of NPCs. Currently, I have a directory macro: /w gm &{template:5e-shaped} {{title=NPCs}} {{text_big=[High-Harbor-Folk](~High-Harbor-Folk) [Southside Syndicate](~Malek) [Cult of the Body Deathless](~Body-Deathless) }} That produces this: To facilitate transportability, all macros are built in as ability macros in a character sheet called "NPCs". The directory macro calls them as ability macro buttons from its own sheet. Thus, clicking "High Harbor Folk" calls the ability macro "High-Harbor-Folk" as shown in the first example. As this grows, I can foresee it becoming unweildy, particularly if I want to tweak the code or update entries. I am using a spreadsheet to parse all the code for me so that all I have to do is enter the data and copy formatted sections of a column into a given macro. Question: Is it possible to have it all built into one uber-macro? Is it possible to nest multiple roll templates within a roll template? I've tried numerous permutations of code, but nothing seems to carry through. The ideal would be to click one button to call up the directory, have the list of NPCs display, and then click the NPC name to give the portrait and bio info. _________ Note: The dragonborn image above is from a Google search of public sources and its ultimate use is within a private game. I make no claim to authorship or permission.
1508986343
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey Keith, to nest roll templates within each other you need, as is usually the case, html code. Specifically in this case the & at the start of the template declaration, and I believe (It's been a while since I did this) all the ending braces ("}"), and the colon in the template definition, as it'll interfere with the button (or you can just put a slash at the start of the button to escape it. [API Command Button containg a Roll Template](!/&amp;#13;&amp;{template:5e-shaped&amp;#125; {{title=Some Template in a button&amp;#125;&amp;#125;)
1508986536
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Editing as a new post to not disturb the html code above: Note that each of these replacements is for a slightly different reason: the & replacement is to prevent an attempted double template declaration the curly braces are replaced to prevent the wrapping roll template from ending early the colon is escaped so that the a element of the button works properly.
1508996563
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks Scott. I'll work with this and see if I can get it to do what I am trying. Still not quite there, but I want to hammer at it till I understand.
1509019404
The Aaron
Pro
API Scripter
Might be easier to just write an api script to output what you want.&nbsp;
1509027381
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Aaron said: Might be easier to just write an api script to output what you want.&nbsp; For you. :) I spent hours working on those exercises you posted, and those were only a dozen or so lines.
1509029932
The Aaron
Pro
API Scripter
Well, I meant "Might be easier (for me) to just write an api script to output what you want (for you)."&nbsp; =D
It's always easier to get you to do a script, but you're always so busy and thus we are forced to actually learn it for ourselves :)
1509030663
The Aaron
Pro
API Scripter
It's just like having children, something else I have plenty of experience with. =D
1509036907
Silvyre
Forum Champion
My personal philosophy is: if it can be done with a macro, it should be done with a macro. :)
I agree that why I have so many hrs on roll20.
1509039787
The Aaron
Pro
API Scripter
Silvyre said: My personal philosophy is: if it can be done with a macro, it should be done with a macro. :) That can is relative.&nbsp; =D&nbsp; There's things you can do in macros that I can't do in them! =D&nbsp; Writing API scripts is much easier for me, and there's very little that has to be worked around if you go that route, at least not that needs to be worked around more than once. =D&nbsp; I only have to figure out how to escape things that go in an API Command Button once, then then I just use that function everywhere.
The Aaron said: Silvyre said: My personal philosophy is: if it can be done with a macro, it should be done with a macro. :) That can is relative.&nbsp; =D&nbsp; There's things you can do in macros that I can't do in them! =D&nbsp; Writing API scripts is much easier for me, and there's very little that has to be worked around if you go that route, at least not that needs to be worked around more than once. =D&nbsp; I only have to figure out how to escape things that go in an API Command Button once, then then I just use that function everywhere. I love your API's and your so good at it and such a help soul like me. I wish I could code as well. Keep up the good work.
1509062837
The Aaron
Pro
API Scripter
Thanks!&nbsp; I do what I can!
The Aaron said: It's just like having children, something else I have plenty of experience with. =D Silvyre said: My personal philosophy is: if it can be done with a macro, it should be done with a macro. :) I had to laugh seeing these two posts back-to-back. :-)
1509066453
The Aaron
Pro
API Scripter
HAHAHAHAHA!!!!
I don't think you can macro that but maybe outsource? ;-)
1509081631
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Silvyre said: My personal philosophy is: if it can be done with a macro, it should be done with a macro. :) That works for me, too. I understand macros a lot better, so if I can figure out how to do something, I'm more able to tweak and repurpose it.
1509219176
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks for everyone's help on this, but I'm reaching the point of diminishing returns. I'll settle for an ability macro directory that creates a roll template to call other ability macros that contain a roll template. It would be nice to be able to have them all in one call, but I just can't seem to get it to work.
1509219228
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
keithcurtis said: Silvyre said: My personal philosophy is: if it can be done with a macro, it should be done with a macro. :) That works for me, too. I understand macros a lot better, so if I can figure out how to do something, I'm more able to tweak and repurpose it. I just realized the other reason I like this philosophy. It allows non-pro users to share solutions. Thanks again.
1509221576
Silvyre
Forum Champion
keithcurtis said: keithcurtis said: Silvyre said: My personal philosophy is: if it can be done with a macro, it should be done with a macro. :) That works for me, too. I understand macros a lot better, so if I can figure out how to do something, I'm more able to tweak and repurpose it. I just realized the other reason I like this philosophy. It allows non-pro users to share solutions. Thanks again. Definitely; that was a major influence (I was a Free user for a long time)!
1509222099
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I'm doing cleanup work on the spreadsheet that generates the macros and the directory macro. I'll start a new thread with that when it's polished.
1509225913
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
And&nbsp; posted .