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

Simple Coding assistance

Hello, Can someone assist me please.  I want a button that will roll a 1d4-1 and then take that number and roll a D6 that many times and reroll any repeats.   So (1d4-1)d6 reroll repeats and then give me the names of characters that where chosen. Number     Character 1                    bob 2                   Joann 3                    Jim 4                    Djinn 5                    Toni 6                    Tony I figured I would ask since it would take me about 2 hours to figure it out and maybe 5 minutes for someone who actually knows what they are doing.   I have a Pro account and I do use Scriptcards.   Thank you
I stayed up all night and I got something usable.   !script {{   --=NumberPeopleSeen|1d4-1   --+Total|Number of People Seen is [$NumberPeopleSeen]   --=WhoCount|[$NumberPeopleSeen]    --:WhoLoop|   --?[$WhoCount] -eq 0|Final   --=WhoCount|[$WhoCount] - 1   --=PersonSeen|1d6   --+Who|They see  [$PersonSeen]   -->WhoLoop|   --^Final|  --X|  --:Final|   --+Done|Thats all they see   }} If anyone knows how to get names to come out instead of numbers, or an easy way to make it reroll repeats I'd appreciate the assistance. 
1740152777
GiGs
Pro
Sheet Author
API Scripter
Failing some miracle working by Tuo or RainbowEncoder, that definitely needs a script. Roll20 macros cannot do iteration (give x results d2-1 times). Is that a ScriptCards script? There's definitely a way to get rollable table results, or convert numbers to text, using that.
1740156910

Edited 1740156945
Kofi
Pro
ahh yes a roll table.  I think I can make that work. Thanks GiGs! Yes its ScriptCards
GiGs said: Failing some miracle working by Tuo or RainbowEncoder, that definitely needs a script. Roll20 macros cannot do iteration (give x results d2-1 times). Is that a ScriptCards script? There's definitely a way to get rollable table results, or convert numbers to text, using that. You called? This actually happened to touch upon several things I've been working on this week, so a solution came to be relatively easily (even if I had to do a bunch of troubleshooting). Doing a thing bounded variable number of times isn't that much an issue, as you can just account for every possible outcome separately, but getting three unique dice rolls is a lot harder. I resolved both by making it a two-click macro: &{template:default} {{name=Number of people seen }} {{=[[[ [[1d4-1]] ]]](!/
 %{@{character_name}|people-seen} {{[[[$[[3.computed]]-1]]]=[ ](#)}} [[1/$[[1.computed]]]] 
%{@{character_name}|people-seen} {{[[[$[[5.computed]]-1]]]=[ ](#)}} [[1/({$[[1.computed]]-1,0}kh1)]] 
 %{@{character_name}|people-seen} {{[[[1d6r$[[3.computed]]r$[[5.computed]]-1]]]=[ ](#)}}[[1/({$[[1.computed]]-2,0}kh1)]] )}}[[ [[1d6r[[ [[1d6]] ]] ]] ]] people-seen &{template:default} {{name=[ ](#" hidden null=) }} {{[0]=[ ](#" hidden null=) }} {{[1]=Bob[ ](#" hidden null=) }} {{[2]=Joann[ ](#" hidden null=) }} {{[3]=Jim[ ](#" hidden null=) }} {{[4]=Djinn[ ](#" hidden null=) }} {{[5]=Tony[ ](#" hidden null=) }} {{[6]=Tim[ ](#" hidden null=)}} Save both of these on the same macro mule, activate the first one, and click the button in the chat, and you'll have 0-3 unique names. I could have made the follow-up output be in a single template, but I wanted to put Divided By Zero Linekill to use. Either way, this was a fun exercise.
1740219301

Edited 1740219787
Andrew R.
Pro
Sheet Author
In ScriptCards you use an array of names indexed by the number you roll.  --~|array;define;Characters;Bob;Joann;Jim;Djinn;Toni;Tony
Works like a charm.  Thank you!