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

Referencing character level or skill in table

December 17 (5 years ago)

Hi, 

Im trying to get a rollable table that does some math as well. All I need is a table that can return 2 + level or skill + 2 with some text. Trying to get Glimpse of redemption randomized this way. Dont seem to be able to make math to work at all and when I reference level or skill with @{level} or @{skill} it just prints @{level} or @{skill}:

The ally gains resistance to all damage against the triggering damage equal to [[2 + @{level}]]

December 17 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Assuming this is an example of your table row:

The ally gains resistance to all damage against the triggering damage equal to [[2 + @{level}]]

Then it isn't going to work.  Inline rolls and attributes don't work in table rows.

The only way to get that behavior is with an API script.


That said, there may be other solutions to your quandary.  I don't know the mechanics you're trying to implement, but maybe if you describe them more fully, someone can find a solution.


December 17 (5 years ago)

Thanks for the response. Inline rolls not working in a table is what I suspected was the issue.

So I run a PF2e game and have an NPC that has this skill that has 2 outcomes. The outcome is supposed to be chosen by the target, but I felt it was too hard for me to do that in this case so I wanted to randomize the outcome. At first, I just had a skill description with both outcomes in a macro that did a [[1d2]] but it was pretty lengthy. This is bit more of a vanity thing but I wanted to see how else this could be done a bit better not only for this but for other uses in the future. Rollable table would be great but not having math work in the row is a bit of a setback. If there was a query I could use that would be selected at random that would work too.

On a side note, is there a way to have the table row not get highlighted with yellow in chat?

Appreciate your time and expertise.

December 17 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

Can you give specifics? What is the code you are using now for the two outcomes?

December 18 (5 years ago)

Sure - here goes:

My table has 2 entries:

  • The ally is unharmed by the triggering damage.
  • The ally gains resistance to all damage against the triggering damage equal to [[2 + @{level}]]
The macro looks like this:
&{template:default} {{name=Glimpse of Redemption}} 
Trigger: An enemy damages your ally, and both are within 15 feet of you.
Effect: Your foe hesitates and [[1t[glimpse-of-red]]]

The output is this:
Glimpse of Redemption
Trigger: An enemy damages your ally, and both are within 15 feet of you.
Effect: Your foe hesitates and The ally gains resistance to all damage against the triggering damage equal to [[2 + @{level}]]

And I expected this for a level 1 character:
Glimpse of Redemption
Trigger: An enemy damages your ally, and both are within 15 feet of you.
Effect: Your foe hesitates and The ally gains resistance to all damage against the triggering damage equal to 3

I'm all for suggestions of how to do it without tables. 

December 18 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

You can do it how its meant to work, having the user choose the effect by using a query. 

If I understand correctly, one player has uses the ability, and another player then pics from two options?

You can do this with two Abilities. 

Call the first one, Glimpse-of-reflection-Trigger, and the macro looks like this:

&{template:default} {{name=Glimpse of Redemption}} {{Trigger=An enemy damages your ally, and both are within 15 feet of you.}} 
{{Effect=[@{Target|character_name} Click Here](~FRODO|Glimpse-of-redemption-Effect)}}

The linebreak is for clarity - remove that in your ability.

Change the word FRODO to the name for the character who has this ability.


Now create a second ability on the same character, called Glimpse-of-redemption-Effect

&{template:default} {{name=Glimpse of Redemption Effect}} {{Choice=?{Pick One|Avoid Damage,The ally is unharmed by the triggering damage|Gain Resistance,The ally gains resistance against the triggering damage equal to [[2 + @{level}]]}.}}


The way it works is. The character with the ability triggers it, and they are prompted to select a target (who must have a token). Imagine they choose a character called Faraam. This is printed into chat:

That is a button which can be clicked. When Faraam clicks it, they rae given the option of choosing to avoid harm, or gain resistance. If they choose gain resistance, it'll print out this:

I've assumed both macros go on the Abilities section of the character who has this spell. If they are in the Macros tab, you need to change this part in the first macro:

[[2 + @{level}]]

to

[[2 + @{FRODO|level}]]

Again, change the FRODO part to the character name.

If you want anyone to be able to use this effects, change all FRODO references to selected.





December 18 (5 years ago)

That's awesome. Thanks for the reply. I could really use that for some feats. 

However, the idea was that I wanted to remove the choice and have it be randomly selected. I wanted to have this be random since its hard for me to select it as I am playing both sides in this case. (NPC attacking NPC)

December 18 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

Sadly, I'm not aware of a way to do it randomly, without the API. Rollable tables could be used if you just want to print out text, but cant have calculations or attribute references in them.

December 18 (5 years ago)

Haven't looked at API yet. But not sure this is a use case I would feel strongly about that would need that much effort.

Thanks a lot for your input and help. Much appreciated!

December 18 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

The API is a Pro subscriber benefit, which is why I didnt try to suggest any solutions using it. 

December 18 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter


Dieter K. said:

On a side note, is there a way to have the table row not get highlighted with yellow in chat?

Not without the API, unfortunately.

December 18 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Table output could probably be re-styled with something like the browser plug-in Stylus, but all players would need to have the extension and the style installed to be able to see the difference.