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

Help with Dice Macro

Okay, so I've read the various help pages, and clearly am still failing, because hitting "Test Macro" does nothing. I'm trying to write a macro that rolls Xd6 and keeps the three best, and then adds the rating of a chosen (dropdown) attribute and a chosen (dropdown) skill, as well as a possible bonus. The only actual rolling is the Xd6k3; everything else is accessing the Attributes to add values (or in the case of the bonus, adding an inputted value). I can get the roll to work, but the instant I try to add the attribute and skill, the Test Macro button just does...nothing. And since there's no error message, I can't figure out what to do. Can I beg someone to toss me working code for this?
1724467858
GiGs
Pro
Sheet Author
API Scripter
Can you post the code you've tried? It's hard to come up with an on-the-fly solution without knowing what the attributes are called.
Without seeing the actual macro in question, nothing showing up suggests to me you have open braces. But like GiGs said, seeing the macro itself would make it much easier to troubleshoot.
1724468660
Gauss
Forum Champion
Starr Saphyre said: Okay, so I've read the various help pages, and clearly am still failing, because hitting "Test Macro" does nothing. I'm trying to write a macro that rolls Xd6 and keeps the three best, and then adds the rating of a chosen (dropdown) attribute and a chosen (dropdown) skill, as well as a possible bonus. The only actual rolling is the Xd6k3; everything else is accessing the Attributes to add values (or in the case of the bonus, adding an inputted value). I can get the roll to work, but the instant I try to add the attribute and skill, the Test Macro button just does...nothing. And since there's no error message, I can't figure out what to do. Can I beg someone to toss me working code for this? Note: Do not use "Test Macro", it may not work properly.  Edit, close, test, repeat.
1724469631

Edited 1724475395
Managed it. This works for my purposes. Now I just have to figure out how to put it in a pretty roll template. UPDATE: Okay, so apparently Roll Templates can't be used for /roll. Is there any way for me to display this, and get an output that shows the chosen Attribute, the chosen Skill, the entered Modifier, and the final value? /roll ?{Number of Dice|3}d6k3 + ?{Attribute Selection| Robustness, @{Selected|Robustness}| Agility, @{Selected|Agility}| Intelligence, @{Selected|Intelligence}| Sensibility, @{Selected|Sensibility}| Charm, @{Selected|Charm} } + ?{Skill Selection| Academics, @{Selected|Academics}| Acrobatics, @{Selected|Acrobatics}| } + ?{Modifier|0}
The ScriptCards Mod allows you to pretty much do anything, but more to your issue, it allows you to make it look however you like. An example is  this dice mod.   It is a whole lot more complicated, however, as it is essentially a full coding language.
1724502410

Edited 1724510589
Starr Saphyre said: UPDATE: Okay, so apparently Roll Templates can't be used for /roll. Is there any way for me to display this, and get an output that shows the chosen Attribute, the chosen Skill, the entered Modifier, and the final value? You'll have to use an inline roll instead of /roll, the rest is quite simple: &{template:default} {{name= Roll}} {{?{Attribute Selection| Robustness, [[@{Selected|Robustness}[Robustness]]]| Agility, [[@{Selected|Agility}[Agility]]]| Intelligence, [[@{Selected|Intelligence}[Intelligence]]]| Sensibility, [[@{Selected|Sensibility}[Sensibility]]]| Charm, [[@{Selected|Charm}[Charm]]] } ?{Skill Selection| Academics, + [[@{Selected|Academics}[Academics]]]| Acrobatics, + [[@{Selected|Acrobatics}[Acrobatics]]] } + [[?{Modifier|0}[Modifier]]]=Result: [[?{Number of Dice|3}d6k3 + ?{Attribute Selection} + ?{Skill Selection} + ?{Modifier}]] }} The same set of queries is used to call and display the same values separately from the roll where it's all added up. If you want the attributes and skills represented in text, you can bake those into the attributes themselves, by making them in the format of [[X[attribute name]]] - that way, when the number is hovered over, you can see what the modifier is from. Note, I didn't test this because I don't have your attributes set up, but as far as I'm aware, it should work. EDIT: I figured out a better way to do the labels, that doesn't require you to alter the attributes, and simplified the macro a little bit. If you have queries with the same name multiple times, the latter copies take the answer of the earlier ones, so they don't need to be fully written out. EDIT2: Cleaned and tested.
1724503926

Edited 1724503942
Tuo has probably given you what you need. But, I've written a scriptcard script that should do what you want as well. I kept it rather simple template-wise, I also included most of the template parameters so you can change them to suit your needs. Also, as Tuo said, I'm also not able to test this completely, as I don't know what sheet you are using. !scriptcard {{ --#title|TITLE --#sourceToken|@{selected|token_id} --#emoteText|EMOTETEXT --#leftsub|LEFTSUB --#rightsub|RIGHTSUB --#bodyfontface|Helvetica --#oddrowfontcolor|#290000 --#evenrowfontcolor|#290000 --#bodyfontsize|[&bodyFontSize]px --#titlecardbackgroundcolor|#930c10 --#titlecardbackgroundcolor|#672223 --#titlefontcolor|#fffebd --#titlefontsize|1.5em --#titlefontshadow|0 --#oddrowbackground|#f7ce65 --#evenrowbackground|#f7ce65 --#oddrowbackground|#b3ab96 --#evenrowbackground|#b3ab96 --#subtitlefontcolor|#fffebd --#tablebgcolor|#fffebd --#lineheight|10pt --#buttonfontsize|10px --#buttonbackground|#930c10 --#buttonbackground|#672223 --#buttonbackground|rgba(103,34,35,1); display:inline-block; --#buttonfontface|Tahoma --#buttonpadding|8px --#bodyfontface|Helvetica --#bodyfontsize|14px --#dicefontsize| 5.0em --#diceFontColor|black --#Debug|0 --&HowManyDice|?{Number of Dice?|1} --?[&HowManyDice] -eq 1 -or [&HowManyDice] -eq 2|&DamageDice;[&HowManyDice]d4|&DamageDice;[&HowManyDice]d4kh3 --&WhatAttribute|?{What Attribute?|Robustness,robustness|Agility,agility|Intelligence,intelligence|Sensibility,sensibility|Charm,charm} --&Attribute|@{selected|[&WhatAttribute]} --&WhatSkill|?{What Skill?|Academics,academics|Acrobatics,acrobatics} --&Skill|@{selected|[&WhatSkill]} --&Modifier|?{Modifier|0} --[&Modifier] -gt 0|&ShowModifier;[b]Modifier:[/b] [&Modifier] -->DieLoop| --X| --:DieRoll| --X| --:DieLoop| --=Damage|[&DamageDice] --&DicePerRow|4 --&DieCounter|1 --&AllDice|[c][t width=100%][tr] --%RollC|1;[$Damage.RollCount] --&AllDice|+[td height=60px][d6][$Damage.RolledDice([&RollC])][/d6][/td] --?[= [&DieCounter] % [&DicePerRow] ] -eq 0|&AllDice;+[/tr][tr] -->IncrementCounter|DieCounter --%| --&AllDice|+[/tr][/t][/c] --?[&HowManyDice] -eq 1 -or [&HowManyDice] -eq 2|=TotalDie;[$Damage.Total] + [&Attribute] + [&Skill] + [&Modifier]|=TotalDie;[$Damage.KeptDice(3)] + [$Damage.KeptDice(2)] + [$Damage.KeptDice(1)] + [&Attribute] + [&Skill] + [&Modifier] --?[&HowManyDice] -eq 1 -or [&HowManyDice] -eq 2|&KeptDice;[c][d6][$Damage.Total][/d6][/c]|&KeptDice;[c][d6][$Damage.KeptDice(3)][/d6] [d6][$Damage.KeptDice(2)][/d6] [d6][$Damage.KeptDice(1)][/d6][/c] --~AttributeName|string;totitlecase;[&WhatAttribute] --~SkillName|string;totitlecase;[&WhatSkill] -->Output| --<| --:IncrementCounter| --&[%1%]|[= [&[%1%]] + 1] --<| --:Output| --+[&AttributeName]:|[&Attribute][hr #d3b63b] --+[&SkillName]:|[&Skill][hr #d3b63b] --+|[&ShowModifier] --+|[&AllDice][hr #d3b63b] --+|[br] --+|[&KeptDice][hr #d3b63b] --+Total|[$TotalDie] --X| }}
1724508072
GiGs
Pro
Sheet Author
API Scripter
If you want to display the name of chosen query item (attribute, skill, etc) as well as the chosen value, you'll need to use nested queries and probably the reusing rolls glitch. It can be done but the code is very complex. Since you're a Pro user, using ScriptCards is a much better solution IMO.
1724509564
timmaugh
Pro
API Scripter
The metascript toolbox can let you use a single query for multiple returns... and you can use that either in isolation or in another script (like ScriptCards). For instance, a simple example using the Metascript Toolbox could be: !You chose ?{Choose an attribute|Agility|Charm|Sensibility}, which has a value of @(selected.?{Choose an attribute}).{&simple} The examples can get more complicated, using tables like lookups to provide expanding support, but it can also be as simple as that.
GiGs said: If you want to display the name of chosen query item (attribute, skill, etc) as well as the chosen value, you'll need to use nested queries and probably the reusing rolls glitch. It can be done but the code is very complex. Since you're a Pro user, using ScriptCards is a much better solution IMO. You could do it with a template nested in a button without having to nest any queries or having to rely on reused rolls, but you'd need to set up separate attributes for the attribute names to call them when needed. Wouldn't be super complex, but the html substitutions necessary are a bit tedious to work out.
To display the chosen Attribute, Skill, and Modifier doesn't have to be complex. Using Tuo's macro as a base you can just take the labels and move them outside the inline roll. In the deconstructed section they will display as text and in the final roll will function as labels. The modified macro being &{template:default} {{name= Roll}} {{?{Attribute Selection| Robustness, [[@{Selected|Robustness}]][Robustness]| Agility, [[@{Selected|Agility}]][Agility]| Intelligence, [[@{Selected|Intelligence}]][Intelligence]| Sensibility, [[@{Selected|Sensibility}]][Sensibility]| Charm, [[@{Selected|Charm}]][Charm] } + ?{Skill Selection| Academics, [[@{Selected|Academics}]][Academics]| Acrobatics, [[@{Selected|Acrobatics}]][Acrobatics] } + [[?{Modifier|0}]][Modifier]=Result: [[?{Number of Dice|3}d6k3 + ?{Attribute Selection} + ?{Skill Selection} + ?{Modifier}[Modifier] ]] }} I also put each initial query on it's own line for clarity and removed the plus from inside the Skill Selection query to prevent double + problems. Final result looking like this
This was the solution that got the closest. :) Thank you all for all your help, though. This taught me quite a bit about macros, and you're all the greatest. :) RainbowEncoder said: To display the chosen Attribute, Skill, and Modifier doesn't have to be complex. Using Tuo's macro as a base you can just take the labels and move them outside the inline roll. In the deconstructed section they will display as text and in the final roll will function as labels. The modified macro being &{template:default} {{name= Roll}} {{?{Attribute Selection| Robustness, [[@{Selected|Robustness}]][Robustness]| Agility, [[@{Selected|Agility}]][Agility]| Intelligence, [[@{Selected|Intelligence}]][Intelligence]| Sensibility, [[@{Selected|Sensibility}]][Sensibility]| Charm, [[@{Selected|Charm}]][Charm] } + ?{Skill Selection| Academics, [[@{Selected|Academics}]][Academics]| Acrobatics, [[@{Selected|Acrobatics}]][Acrobatics] } + [[?{Modifier|0}]][Modifier]=Result: [[?{Number of Dice|3}d6k3 + ?{Attribute Selection} + ?{Skill Selection} + ?{Modifier}[Modifier] ]] }} I also put each initial query on it's own line for clarity and removed the plus from inside the Skill Selection query to prevent double + problems. Final result looking like this
1724706959
GiGs
Pro
Sheet Author
API Scripter
RainbowEncoder said: To display the chosen Attribute, Skill, and Modifier doesn't have to be complex. Using Tuo's macro as a base you can just take the labels and move them outside the inline roll. In the deconstructed section they will display as text and in the final roll will function as labels. The modified macro being &{template:default} {{name= Roll}} {{?{Attribute Selection| Robustness, [[@{Selected|Robustness}]][Robustness]| Agility, [[@{Selected|Agility}]][Agility]| Intelligence, [[@{Selected|Intelligence}]][Intelligence]| Sensibility, [[@{Selected|Sensibility}]][Sensibility]| Charm, [[@{Selected|Charm}]][Charm] } + ?{Skill Selection| Academics, [[@{Selected|Academics}]][Academics]| Acrobatics, [[@{Selected|Acrobatics}]][Acrobatics] } + [[?{Modifier|0}]][Modifier]=Result: [[?{Number of Dice|3}d6k3 + ?{Attribute Selection} + ?{Skill Selection} + ?{Modifier}[Modifier] ]] }} I also put each initial query on it's own line for clarity and removed the plus from inside the Skill Selection query to prevent double + problems. Final result looking like this That's a great way to do it if you don't want them in separate rows. Any method that avoids nesting queries is good!