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

Can you reference an attribute in an attribute reference?

January 30 (4 years ago)
J R.
Plus

So, to begin with, I'm a free user with no access to API.

Short version:

What I'm looking to do is have this return a useable attribute reference: @{DMsheet|Bonus@{selected|Bar3}}


Long version:

My group has the ability to pop a party-wide bonus on Attack rolls, and it increases each turn (similar to, but not, an Escalation Die). I use the Turn Tracker to keep track of this and make sure that I'm updating it each round. We have relatively recently learned how to reference the Bonus in the tracker, making it a lot easier to add it into our rolls, but when the party hasn't activated Bonus, it's not on the boards, and the macros complain that there is no @{tracker|Bonus} to reference.

I first though to add it as a query in the rolls as to whether it was active, but the macro still goes looking for @{tracker|Bonus} at the start of the macro implementation, in case I want to use it, and complains when it can't find it and breaks itself out of spite.

I then thought to use a bouillon function and program two separate attributes: Bonus1 (which would contain the @{tracker|Bonus} reference) and Bonus0 (which would just be set to '0'), and turn it off and on from a token giving us @{DMsheet|Bonus@{selected|Bar3}}, but it references attributes from left to right instead of inside out and so it fails. And since it does calculations after attribute references, I can't use that to make it find the status of Bar3 first.

I can make two separate attack macros, one which references Bonus and one that doesn't, but that's inelegant (and eats up room on the dashboard or button menu).

I can plug [[ 0 + @{tracker|Bonus} ]] instead of the vanilla @{tracker|Bonus} and the macro no longer breaks, but it still complains for each instance it is supposed to be referenced.

I can add a Bonus in the turn order, set to '0', and leave it there no matter what the party does, but that feels clunky, especially when they don't activate it during the encounter.


Any suggestions on how to make this work?

January 30 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

If you add &{noerror} to the macros, it might stop giving you the error reports.

J R. said:

What I'm looking to do is have this return a useable attribute reference: @{DMsheet|Bonus@{selected|Bar3}}

<snip>
Any suggestions on how to make this work?

You cant build up attributes like that, unfortunately. Here's a different method to handle it without using the turn tracker.


If you have a checkbox that has value="1" for whether the bonus is active (called, say, bonus_check), you can then do something like

[[@{bonus_check) * @{bonus}]]

to get the current bonus.

If you store them on a GM character, called GM, and create a token linked to that character (maybe keep it on the GM player so players don't see it), then you could link those two attributes to a token's token bars, making it easy for you to adjust them on the fly. And then you would get their values by including something like this in the players macros:

[[@{GM|bonus_check) * @{GM|bonus}]]

Technically you only need one attribute, bonus, which you can reset to zero when needed. Son thee attribute always exists, you dont get any errors.



January 31 (4 years ago)
J R.
Plus

Thanks GiGs!

The Turn Tracker is an important part of the process because about a third of my players like to create their rolls each time and the others like doing macros, so I need it to be visible for the players that don't wanna macro (for some alien reason or another). I added the &{noerror} into my [[ 0+ @{tracker|Bonus} ]] and it works beautifully! Although, I need to be careful, it seems that it affects the whole of the macro and not just the part that's contained within the calculation brackets with it.

Enjoy yourself!

January 31 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

Great!

Yeah, it'll suppress all errors not just that one, so its best to use it with well-tested macros where you know what the soure of errors can be and have them managed.