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

Reusing Input Variables

1678297736

Edited 1678298723
I have minimal skills at writing macros. I'm decent at taking ones that have been created and adapting them to what I want, but this one is stumping me. &{template:default} {{name=Sorcery Challenge}} {{Effect Level=?{Enter the effect level of the sorcery | }}} {{Depletion=?{Enter the depletion of the sorcery | }}} {{Challenge Level=[[@{Effect Level}+@{Depletion}+1]]}} {{Sorcery Investment=@{Challenge Level}}} {{Days to Complete=[[@{Challenge Level}*2]]}} The idea behind this macro is that it asks for the effect level and the depletion level being used add +1 and then does some math to display: Challenge Level - Effect Level + Depletion + 1 (Which also equals sorcery investment) Days to complete - Challenge level * 2 I know the issue stems from: {{Challenge Level=[[@{Effect Level}+@{Depletion}+1]]}} {{Sorcery Investment=@{Challenge Level}}} {{Days to Complete=[[@{Challenge Level}*2]]}} But am unsure of how to address it. Any advice here would be welcome.
1678298302
Gauss
Forum Champion
First, your queries do not need "|" pipes if there is nothing after them. Instead use ?{Enter the effect level of the sorcery} without the pipe. Next, your first step when making a macro...substitute all attribute values and codes into the macro.  So for your original macro:  &{template:default} {{name=Sorcery Challenge}} {{Effect Level=?{Enter the effect level of the sorcery | }}} {{Depletion=?{Enter the depletion of the sorcery | }}} {{Challenge Level=[[@{Effect Level}+@{Depletion}+1]]}} {{Sorcery Investment=@{Challenge Level}}} {{Days to Complete=[[@{Challenge Level}*2]]}} Substitute @{Effect Level}, @{Depletion}, and @{Challenge Level}'s contents into the macro. Then you will see what might break.  If you post the contents of those attributes we can see what might be breaking things.
Substitute @{Effect Level}, @{Depletion}, and @{Challenge Level}'s contents into the macro. Then you will see what might break.  If you post the contents of those attributes we can see what might be breaking things. Those aren't attributes in the sense of Strength, Dexterity, Stamina, etc. I'm trying to find a way to use the input values of (Effect Level), (Depletion) to calculate into (Challenge Level) and then use them to display information. When pressed the macro button should ask for the Effect Level number, the Depletion number, then calculate the Challenge Level by adding those two numbers + 1. The last calculation takes the Challenge level and multiplies it by 2 for the Days to complete for the following display: Sorcery Challenge Effect Level - # Depletion - # Challenge Level - # Days to Complete - #
1678300068

Edited 1678301580
Gauss
Forum Champion
If you want it to ask for something you will want to use queries instead of Attributes.  One thing I think you are confused about is you are calculating things multiple times then trying to reference the earlier calculation as an @{attribute}. It doesn't work that way.  Queries can be listed multiple times, but a given query will only be popped up once. Each instance of that query will get the same answer.  So here is how I would rewrite it: &{template:default} {{name=Sorcery Challenge}} {{Effect Level=?{Enter the effect level of the sorcery}}} {{Depletion=?{Enter the depletion of the sorcery}}} {{Challenge Level=[[?{Enter the effect level of the sorcery}+?{Enter the depletion of the sorcery}+1]]}} {{Sorcery Investment= [[?{Enter the effect level of the sorcery}+?{Enter the depletion of the sorcery}+1]] }} {{Days to Complete=[[[[?{Enter the effect level of the sorcery}+?{Enter the depletion of the sorcery}+1]] *2]]}} So, when you have ?{Enter the effect level of the sorcery} multiple times, it only pops up one query, and the answer is put into each instance of ?{Enter the effect level of the sorcery}. Note: I would clean that up further to make it easier to read instead of a mess of duplication of queries, but that gets into a different element of macro writing and I want to present the more basic (less clean) solution to you first.  The cleaned up version looks like this:  &{template:default} {{name=Sorcery Challenge}} {{Effect Level=$[[0.computed]] }} {{Depletion=$[[1.computed]] }} {{Challenge Level=$[[2.computed]]}} {{Sorcery Investment=$[[2.computed]]}} {{Days to Complete=[[[[[[?{Enter the effect level of the sorcery}]]+[[?{Enter the depletion of the sorcery}]]+1]]*2]]}} Cleaned up version is using reusing rolls to clean up the template.  Edit: This will output the following template:  Sorcery Challenge (name of the template) Effect Level (answer to the query) Depletion (answer to the query) Challenge Level (sum of 1 + Effect Level query + Depletion level query) Sorcery Investment ( sum of 1 + Effect Level query + Depletion level query ) Days to Complete (sum of 1 + Effect Level query + Depletion level query, then multiplied by 2)
That works perfectly, thank you. I see how you got there.