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

Calling a Variable from a Character Sheet

So, once again, playing a Pokemon 5e TTRPG, and I am thinking I should set up a macro for the different Pokeballs that will be used in the future. So, I figured I could do a list macro, calling on the Animal Handling check needed for the roll, add on the ball's bonus, and make it a simple prompt I could maybe share with the others in my party. Of course, its not being simple... Pokeball, Jake threw a Pokeball! [[@{animal_handling} + 0]] That is part command I got set up within the character sheet, as the other balls would be more copy pasta and number changes, but when I test it, I get: No attribute was found for @{Jake Dressel|animal_handling} When I try to set it to @{animal_handling_roll}, it changes from a list query to an input query, so there must be something wrong, I could be calling the variable wrong or a strange call is somehow being made. I am sorry if this feels like a newbie issue, but this is my first time trying to directly call a number from a character sheet. If needed, I can copy-paste the full command I am using as my basis and editing (a potions macro)
What sheet are you using? This seems like an issue of calling the wrong attributes, and without taking a look at the sheet itself, I can't help more.
1726114500

Edited 1726114566
Oh, I guess that info would help. We are using the standard DnD 5e sheet. You know, with the Stats column, Attack column, and Personality column. Not sure how else I would label it as... Not the new 5e sheet, at least.
Oh, you mean the DnD 5e 2014 sheet? That makes things easier. @{animal_handling_roll} contains the template for the roll, so you can't put it inside an inline roll. If you want to reconstruct the roll in your own macro or template in an inline roll, it's [[@{d20}+@{animal_handling_bonus}]], plus any more changes you like within that inline roll.
Huh. Wish they made it a bit simpler, but ah well. Either way, that helps me out, so thanks ^^
Its a touch messy, but gets the job done, as well as easy to add more to it. &amp;{template:default}{{name=Pokeball, go!}} {{?{Pokeball Type| Pokeball, Jake threw a Pokeball! [[(@{d20}+@{animal_handling_bonus})[Animal Handling] + 0]]| Great Ball, Jake threw a Great Ball! [[(@{d20}+@{animal_handling_bonus})[Animal Handling] + 5]]| Ultra Ball, Jake threw an Ultra Ball! [[(@{d20}+@{animal_handling_bonus})[Animal Handling] + 10]]| Hyper Ball, Jake threw a Hyper Ball! [[(@{d20}+@{animal_handling_bonus})[Animal Handling] + 20]]} Here's hoping!}} What's strange, though, is that when it outputs, it gives me: {{ Jake threw an Ultra Ball!&nbsp; <span class="inlinerollresult showtip tipsy-n-right" title=" Rolling (1d20+6)[Animal Handling] + 10 = (( 6 )+6)+10" style="box-sizing: content-box; background-color: var(--primary-dark); border: 2px solid var(--primary-dark); padding: 0px 3px; font-weight: bold; cursor: help; font-size: 1.1em; color: rgb(179, 179, 179);">22 Here's hoping!}} I wonder why the curly brackets are still there in the output...
1726118622

Edited 1726118993
Line breaks between the template elements break the template - the parser considers the template to have ended when it encounters a line break that's not within an element. Just make sure that the {{ starts on the same line as the previous }}, and it'll work fine. EDIT: To further clarify, line breaks cut off the parser except within double braces - double braces tell the parser "yes, this is still part of the same thing".
So, basically, I broke it when I was trying to be too tidy XD Of course. Well, at least its as easy of a fix as to erase an enter key. So as long as its withing a pair of braces, its fine to use enter to sort, but outside, I need to keep them connected. So if I wanted to be a bit sorted with bracket lines, I would go: {{Something Something}} {{ Something Songthing}} {{ Something Something}} That would not break the code?
1726120507

Edited 1726123624
That would not break the code, though I'd suggest placing the line break before the closing braces, rather than in after the opening braces - in a template, if there's content after a line break, the line break is rendered, but not if there's no content - so if you don't want undue empty space in your template, it's better to place the line break after the content. So {{content1 }} {{content2 }} {{content3}} EDIT: As a little aside, anything that is on a line with a template that's not contained in double braces is parsed but not displayed - so you can use it to hide things, such as comments, or rolls and queries for some advanced tricks.
Thanks for all the tips and such ^^ But a little confused how the added comments thing is being done there, and with even minor comments helping explain a bit more complex tasks, any chance you could elaborate more? Or is it just like {{Content }} This comment will not be registered {{Content}}
1726158737

Edited 1726158875
The comment is parsed, but not displayed: Text here is hidden &amp;{template:default} Here too {{Content 1 }} This roll here is made, but not shown [[1d10]] {{Content 2 }} You can put stuff here too, and it won't be displayed But here we're on a line without a template, so this text is displayed under the template. There's a few tricks involving reusing rolls by calling them by their roll index &nbsp;- where the actual roll is made in relation to where it's called is often relevant, so the ability to place the real roll out of sight in a place of your choosing can be very useful - and you can use the property of matching queries duplicating their input for some fairly niche applications, like recursively adding to a dice roll, or inserting a query option into a called template that didn't have that option defined. But, this is fairly arcane stuff.
1726167647

Edited 1726168732
Or say, "This attack dealt 2d6 damage, and you absorbed half of it," you can call on that specific roll and do the /2 and just show the result f the gain and not pen it on the side. Wait, could that also be done so I can only do that Animal Handling call at the start and jsut apply the result at what bonus I want to give it to and not have the call ready at every instance? Edit: A quick test gave me a result of: Ultra Ball, Jake threw an Ultra Ball! [[$[[0]] + 10]]| Jake threw an Ultra Ball! [[ 7 &nbsp;+ 10]] So it showed the roll, but did not add it together with the number I wanted and even had the bracket from the original base I set...
1726171467
Gauss
Forum Champion
Hi MagusAndrus,&nbsp; With certain exceptions (that only a couple people understand) you cannot perform math functions on computed values ($[[0]]).&nbsp; Instead, perform all calculations first, then break it out.&nbsp; Example: [[[[2d6]]/2]] $[[0]] is the 2d6 and $[[1]] is 2d6/2
1726172095

Edited 1726173488
Okay, so then I'd have to nest up all the formulas for one part to seem cleaner, or make the code a bit more on the chunkier side. Either way, I cannot get away with all the math calls under a single roll call. I mean, imagine the DM seeing 5 dice roll at once when only one gets shown if they have that enabled XD So then its up to me on whether I want the code to look bulkier but getting a solid 17 or much cleaner and dealing with 7+10... Or I just got to do some crazy nesting! I mean, except for one varied exception, they all work in increments of 5! &nbsp;[[[[[[[[[[(1d20+@{animal_handling_bonus})]]+5]]+5]]+5]]+5]] Sadly, this means outside of the $[[0]], you cannot really call upon the roll without seeing the physical die, but can't get everything without a mess XD Especially with how much more limited macros can be outside of actual coding.
1726176340

Edited 1726176862
Gauss
Forum Champion
Well, this already happens in various character sheet designs, multiple dice are rolled even if they are not used (displayed).&nbsp; Example: critical hits damage is rolled even if you didn't roll a critical hit.&nbsp; With that said I am not sure why you would get multiple dice rolls for your example. It is one die roll, displayed in a variety of ways.&nbsp; This only has one dice roll: 2d6. &amp;{template:default} {{name=example}} [[[[2d6]]/2]] {{Damage=$[[0]]}} {{Damage halved=$[[1]]}} Regarding calling upon the roll without seeing the physical die, that is simple, just include a line in your template where you display the original die roll.&nbsp;
1726179955

Edited 1726182643
I'm a little confused on what you're working over - there is no major downside to rolling all of the options at the same time (only that resolving a lot of rolls at the same time can take more time) - not even the GM sees the unselected rolls. But, there is a simpler, faster way to set your query up that doesn't require any fancy tricks or multiple rolls - you just need to split the roll in half, with half of the roll in the query and the other half after it - so, the only thing you'd query for is the ball name and modifier. Jake threw a ?{Pokeball type?|Pokeball, pokeball! [[|Great Ball, Great Ball! [[5+|Ultra Ball, Ultra Ball! [[10+|Hyper Ball, Hyper Ball! [[20+}1d20 + @{animal_handling_bonus}]] Queries are resolved before inline rolls, so splitting the inline roll with a query shouldn't cause problems. I am not on my PC right now, though, so I didn't test this myself. As general advice, though, I wouldn't worry too much about how the macro looks when laid out, as long as it does what you want it to. Readability is good, but sometimes you need to compromise for the sake of function. EDIT: If above breaks, try replacing the opening square brackets in the query with&nbsp; HTML entities . I can't check right now if it does break, but if it does, that should fix it - html entities within queries are resolved with the query. EDIT2: Oh right, because queries are resolved before inline rolls, you wouldn't get multiple rolls anyway. But it's still good practice to reduce queries to their smallest necessary components most of the time, because queries are prone to causing trouble.
Oh, that was because my brain confused nesting wrong and was thinking [[roll +0]] [[roll + 5]] etc before realizing what I actually did XD Wow, I didn't even think that breaking up the brackets would work like that o.o huh. But ultimately, my DM sees my code so its not like there be much issue anyways. And its set in a way I oculd plug in more options if/when needed