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

Linking queries to a table?

So I'm trying to make a button easier for some of my players.  I would like for my player, whose character is a jewelcrafter, to be able to press one button, make a couple choices, and see on screen whether his roll beats the DC.  I've done something similar for a fletching character.  The problem is that fletching has a standard set of rules for increased DC for better arrows: shaft type sets the base DC, then different points, fletchings, and nocks all increase the DC by a set amount per type.  That button was easy enough to create thusly: /em sits down to make some arrows /w gm ?{Shaft|Wood,10|Bone,13|Ceramic,16|Steel,19} ?{Point|Steel,0|Silver,3|Velium,6|Acrylia,14} ?{Fletching|Round,0|Parabolic,5|Shield,10} ?{Nock|Large,0|Medium,1|Small,3} Tradeskill (fletching): [[1d20+@{Tradeskill (fletching)}[ranks]+@{Wis mod}[wis]+2[masterwork kit]+1[synergy]]] vs DC [[?{Shaft}+?{Point}+?{Fletching}+?{Nock}]] I want to make something similar for jewelcraft, where he can choose the metal and the gem and it outputs the DC based on what the metal/gem combination would be.  Unfortunately, I can't just put a base DC for each metal and add for gems as they don't quite work that way.  For example: Gem: Carnelian; Metals with DCs: Silver, 8/Electrum, 12/Gold, 18/Platinum, 22/Velium, 27 Gem: Amber, Metals with DCs: Silver, 9/Electrum, 13/Gold, 19/Platinum, 27/Velium, 35 Gem: Azurite; Metals with DCs: Silver, 10/Electrum, 14/Gold, 20/Platinum, 26/Velium, 32 Just to show the earliest discrepancies.  I would love to just use the lowest DCs per metal and add based on gem, but the gems don't add DC equally for each metal.  Is there a way to create a table that the macro can pull from based on inputs of gems and metals?
1622839145
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Sure, make your rollable tables with the following naming scheme: Gem-Metal And then have only one value in each table, the DC for that combination. So, for instance Carnelian would have: carnelian-silver carnelian-electrum carnelian-gold carnelian-platinum carnelian-velium Then your macro would be: [[1t[?{Gem|Carnelian,carnelian|Amber,amber|Azurite,azurite}-?{Metal|Silver,silver|Electrum,electrum|Gold,gold|Platinum,platinum|Velium,velium}] ]]
The things I'm willing to do for my players lol
1622846379
The Aaron
Roll20 Production Team
API Scripter
The things I'm willing to do for other player's GMs, lol Here's a command: !csvt carnelian-silver 8 It will create a table with that name and give it a single row with whatever is after the name.  Hope that helps! =D Script: on('ready',()=>{ const buildArgs = (str) => { let firstWhitespace = str.search(/\s/); if(-1 === firstWhitespace){ return [str]; } return [str.slice(0,firstWhitespace),str.slice(firstWhitespace+1)]; }; on('chat:message',msg=>{ if('api'===msg.type && /^!csvt(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let args = buildArgs(msg.content.replace(/^!csvt\s*/,'')); if( 2 === args.length){ let t = findObjs({type: 'rollabletable', name: args[0]})[0]; if(t){ sendChat('Create Single-value Table',`/w "${who}" <div><b>Error:</b> Table with name <code>${args[0]}</code> already exists.</div>`); } else { t = createObj('rollabletable',{name: args[0], showplayers: false}); if(t) { createObj('tableitem', { name: args[1], rollabletableid: t.id}); sendChat('Create Single-value Table',`/w "${who}" <div>Created <code>${args[0]}</code>.</div>`); } else { sendChat('Create Single-value Table',`/w "${who}" <div><b>Error:</b> Failed to create table with name <code>${args[0]}</code>.</div>`); } } } } }); });
You, sir, have made me very happy.  This is beautiful, thank you so much
1622847195
The Aaron
Roll20 Production Team
API Scripter
No problem =D