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

How to call a macro...

1627435611
I have this in my character sheet... <input type='text' name='attr_spell_macro'/> <button type='roll' value='WHAT GOES HERE?' name='roll_spell'> Info/Cast</button> And I want to call a custom macro (by macro name) that I created in another character sheet using the value property of the <input> element. Is there a way to do this using this method? If so, what's the syntax?
1627442726
Kraynic
Pro
Sheet Author
Assuming there will be a token associated with that other sheet on the vtt, the easiest would probably be @{target|spell_macro}.  Actually, I'm not sure there is another way, because you would need to have the name of the other sheet coded in otherwise in place of target.  Target is also the only way to grab a value from a sheet for which the person running the macro doesn't have edit permission. 
1627445612
Well, I'm trying to adapt a technique I've seen work where the other character sheet is called by name using a chatmenu and the syntax (~sheetName|macroName). The selected token/sheet has edit permissions but not view permissions. Works fine when called from a local macro to the other sheet's macro. Sooo, I figure I could  try and call the other sheet's macro from a roll button's value field via another field's value, but it doesn't seem to work. All I get is the actual text of the value field. For example, let's say there's a macro in a sheet called Magic-User Spells, labeled "My-Spell". I want to be able to enter that reference into the <input> element's field, so, like this... <input type='text' name='attr_spell_macro'/> <button type='roll' value='@{spell_macro}' name='roll_spell'> Info/Cast</button> For example, enter "(~Magic-User Spells|My-Spell)" in the <input> field on the sheet and then click the button. I want  the macro in the Magic-User Spells character sheet to execute, but all I get is "(~Magic-User Spells|My-Spell)" in the chat window. I'm doing this because I'm modeling Basic Fantasy's spell preparation system, and I really want my players to do this inside  the character sheet, and not have to mess with a list-macro, because in BFRPG they can change out their prepared spells every in-game morning, and who wants to be editing a chat-menu list macro over and over? Then, they could use a chatmenu macro to display all their prepared spells and click one spell (linked in the other character sheet) to display the spell's description in their game's chat panel. (BTW, @Kryanic, I may have gotten this idea from your Paladium Fantasy chatmenus - Genius!) The question is , how to call a macro in another character sheet in this fashion? Can it be done?
1627448927

Edited 1627448980
GiGs
Pro
Sheet Author
API Scripter
omonubi said: For example, enter "(~Magic-User Spells|My-Spell)" in the <input> field on the sheet and then click the button. I want  the macro in the Magic-User Spells character sheet to execute, but all I get is "(~Magic-User Spells|My-Spell)" in the chat window. This is the wrong syntax. That would only work if you are creating a button in chat, and you would need to supply a button label, like [My Spell](~Magic-User Spells|My-Spell) without the [label], the bracketed bit following isn't recognised as a macro or ability. To call an ability on a sheet directly, you use this format: %{Magic-User Spells|My-Spell} So that's what you'd need to type into the input.
1627482612
And you are so right, GiGs. It worked. Thanks, again!
1627486139
Andreas J.
Forum Champion
Sheet Author
Translator
Hmm, seems we should have a better section that clearly summarize the different ways to reference macros. <a href="https://wiki.roll20.net/Macro_Guide#Chat_Commands" rel="nofollow">https://wiki.roll20.net/Macro_Guide#Chat_Commands</a> is the closest thing I know we have, but it's not great for an overview.