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

How to show a user-entered text attribute in a roll macro?

September 28 (4 years ago)

Hi all,

I'm making my first custom character sheet, and I'm unable to show a text attribute (entered by a player in their sheet) in a roll macro result - help very much appreciated!

This is for a character sheet's table of equipment. The idea is that players add their equipment to it as they play, by entering its name in the first column (then selecting its Ability, assigning proficiency, checking "owned" and "equipped" checkboxes... etc). The table also provides a roll button for each row...

So I have the first cell named "attr_Equipment1_Name", with its value set to blank (value="").

In the sandbox sheet, I've entered "Radio", so I'd like to see:

*CharacterName* rolls Radio *result*

<td><button type="roll" class="sheet-btn" name="roll_Equipment1" value="/e rolls  *attr_Equipment1_Name* [[1d20+ability and proficiency maths]]" style="width:25px">Roll</button></td>

I've gone through a pile of syntax ( {, [,[[, field|value...) without luck, and my forum searches aren't finding this topic - is this possible please, or does this text need to be hardcoded?

I can see that a dropdown selection list of 'all possible equipment' would be one hack, but I'd rather leave it open for the players to add anything.

Thanks very much in advance!

September 28 (4 years ago)
David M.
Pro
API Scripter

If the sheet writes to an actual attribute (found in the Attributes & Abilities tab), you should be able to reference it directly in your macro with @{CharName|AttrName}, unless I am misunderstanding the problem.

September 28 (4 years ago)

Edited September 28 (4 years ago)
Andreas J.
Forum Champion
Sheet Author
Translator

Sheet attributes are referenced by @{attributename}

So the above code should be :

<button type="roll" class="sheet-btn" name="roll_Equipment1" value="/e rolls @{attr_Equipment1_Name} [[1d20+ability and proficiency maths]]" style="width:25px">Roll</button>


David M. said:

If the sheet writes to an actual attribute (found in the Attributes & Abilities tab), you should be able to reference it directly in your macro with @{CharName|AttrName}, unless I am misunderstanding the problem.

This is the case with general macros that are not built into character sheets or Ability calls, but when making macros that are in roll buttons, the name should be left out as it automatically targets the sheet it is inside(and can only use stats from it's own sheet.


OP, I suggest you get familiar with the Building Character Sheets documentation, specifically Roll Buttons and Complete Guide to Macros & Rolls will help you out to find details like this.

Looking at Sheet Examples will also help you out greatly to figure out basic things like this.

September 28 (4 years ago)
Finderski
Sheet Author
Compendium Curator

One slight correction, you should leave the attr_ off the call, so it should looks like this:

<button type="roll" class="sheet-btn" name="roll_Equipment1" value="/e rolls @{Equipment1_Name} [[1d20+ability and proficiency maths]]" style="width:25px">Roll</button>
September 28 (4 years ago)
David M.
Pro
API Scripter

Ahh, thanks for the clarification, Andreas!

Andreas J. said:

This is the case with general macros that are not built into character sheets or Ability calls, but when making macros that are in roll buttons, the name should be left out as it automatically targets the sheet it is inside(and can only use stats from it's own sheet.


September 28 (4 years ago)

Hi All,

Thanks very much for the quick help with this.

I was missing the need to drop the "attr_" prefix from the @{AttributeName} string (thanks Finderski!)