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

Roll Query calling a roll table...

Ok, so a nice simple question... is it possible for a macro to use a roll query to call up different roll tables ? For example, the query is something like  &{template:default}?{Sex|male|Female} And then I have two roll tables, one giving random male names, one random female names.... What do I need to put into the macro to call up the roll table from the selection made ?
1586193278

Edited 1586193296
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
There are two ways to handle this. You can put the full table call in the query, or use the query value for the table name. I prefer the second option which would look like this assuming two sets of tables (male/female-name & male/female-hair): &{template:default} {{name=NPC generator}} {{Character Name=[[1t[?{Sex|male|female}-name] ]]}} {{Hair=[[1t[?{Sex|male|female}-hair] ]]}}
First of all, thanks for the help... I've followed your example, and while it does ask the question... there is no output from a roll table on selection of either of the options... here is the macro as I have it written... &{template:default} {{name = Relationships}} {{Position =[[1t[?{Position|Ally|Rival}[CG-Ally-Relationships] ]]}}{{Position =[[1t[?{Position|Ally|Rival}-[CG-Rival-Relationships] ]]}} I'm guessing I did something wrong here...
1586195646
GiGs
Pro
Sheet Author
API Scripter
You have this as a table call 1t[?{Position|Ally|Rival}[CG-Ally-Relationships]  but it should be 1t[?{Position|Ally|Rival}CG-Ally-Relationships]  the query is part of the table name. The tables would need to be called AllyCG-Ally-Relationships RivalCG-Ally-Relationship
Ok, so I changed it to match what you  have put there, it now reads &{template:default} {{name = Relationships}} {{Position =[[1t[?{Position|Ally|Rival}CG-Ally-Relationships] ]]}} {{Position =[[1t[?{Position|Ally|Rival}CG-Rival-Relationships] ]]}} Still no output.. I have changed the name of the roll table as you mentioned... strangely though, If I remove the latter part of the macro, so that it reads... &{template:default} {{name = Relationships}} {{Position =[[1t[?{Position|Ally|Rival}CG-Ally-Relationships] ]]}}  And you then select Ally as the output, it works fine... but when both options are there, no output at all...
1586205276
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
No output at all when you do the second one? I've created some random tables in a test game of mine, and your code above works as it should, although probably not how you thought it would. That caveat is because of how roll templates work. Only a single instance of a given roll template field can be used in a roll template. Additional uses of that field will overwrite previous uses of the field in the macro. The roll template fields are indexed for this purpose based on the value to the left of the equal sign (=). So, you are using the Position_ field twice (the underscore is put there for the space you have after position). So, if you want both fields to show up you need to do something like this: &{template:default} {{name = Relationships}} {{Position1=[[1t[?{Position|Ally|Rival}CG-Ally-Relationships] ]]}} {{Position2=[[1t[?{Position|Ally|Rival}CG-Rival-Relationships] ]]}} Note that instead of numbering the positions, you can use different numbers of spaces in the field name (e.g. "Position" vs. "Position "), but this can quickly become difficult to read when you are troubleshooting your code. Now, if you aren't getting any output at all, I'd check to make sure your tables are named what you think they are.
Yeha, that one didnt work either.. Im not sure why it works for you but not me...I have copy/pasted what you put up there... altering the name of the roll table so that it matches the roll table exactly (also copy and paste to be 100% sure) and there is no output at all. &{template:default} {{name = Relationships}} {{Position1=[[1t[?{Position|Ally|Rival}AllyCG-Ally-Relationships] ]]}} {{Position2=[[1t[?{Position|Ally|Rival}RivalCG-Rival-Relationships] ]]}} I know that I could fix the issue by just creating two macros, one for each... I'm just trying to stream-line the work into as few macro's as possible...With this one included the addon I'm making already has 3 macros and about 40 roll tables, so im trying to get it down as much as is possible... Thanks for all the time and effort your putting into this, its greatly appreciated.
1586207789
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Well, can you take a screencap of your rollable tables? and I notice that your table calls have changed again to add ally/rival between the query and the "CG"
1586209958

Edited 1586210257
sure thing.... I altered the names because an earlier post said that I would need to change the name of the tables.
1586210736

Edited 1586210748
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Right, but the name of the tables needs to match what the final output including the query will be. so, your macro needs to get rid of that ally/rival between the query and "CG".
So the macro currently reads... &{template:default} {{name = Relationships}} {{Position1=[[1t[?{Position|Ally|Rival}CG-Ally-Relationships] ]]}} {{Position2=[[1t[?{Position|Ally|Rival}CG-Rival-Relationships] ]]}} And I altered the name of the two tables back to  CG-Ally-Relationships CG-Rival-Relationships Still no output from either choice though
1586211389

Edited 1586211525
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
No, the table name and the name of the table in the macro being called have to be the exact same. The result of the query gets put exactly where the query is. So, Do I understand correctly that you want to call one of these tables based on the result of the query (either ally relationships or rival relationships, not both)? If that's the case, you don't need the position 2 field, and you just need to take your query and put it where Ally is in your first table call. This looks like this: &{template:default} {{name=Relationships}} {{Position1=[[1t[CG-?{Position|Ally|Rival}-Relationships] ]]}} EDIT: I would also remove the space after name so that you can have the name in the actual header portion of the macro. I've done so above.
Thanks so much... that fixed the problem.. and is working perfectly :D Honestly, thanks