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

Inserting the results of a roll table into the text of link

1666747280

Edited 1666752954
Tara
Pro
So I'm trying to style the output of the text I get when I call something lie [[1t[Trinkets]]] using this method . I created this macro: &{template:npcaction} {{rname=?{Table Name}}} {{description=[[[1t[?{Table Name}]]]](" style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 12px; color: #3163f7;")}} and it gives me the correct style, but not the correct text: If I add space around the inline roll, I get the correct text, minus the style: The way the text looks in that screenshot is the same way it would look if I just omitted the style altogether along with the extra square brackets. Does anyone know how to insert the text of the result of an inline call to a roll tablet into a link in order to be able to apply the css to it?
I think you need to use Recursive tables mod. Is on the Mods (API) Library.
Warlord said: I think you need to use Recursive tables mod. Is on the Mods (API) Library. Sadly, that doesn't seem to be doing anything. I added the API and ran !rt &{template:npcaction} {{rname=?{Table Name}}} {{description=[[[1t[?{Table Name}]]]](" style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 12px; color: #3163f7;")}} And there was just no output at all
I think with recursive tables spacings are very important The syntax to call a table with recursive table is  !rt [[ 1t[Encounters] ]]. plus you are adding the style you want. Your best bet is if The Aaron can help.
1666880369

Edited 1666880741
timmaugh
Forum Champion
API Scripter
Another option would be to use ZeroFrame to extract the value from the inline roll: !&{template:npcaction} {{rname=?{Table Name}}} {{description=[\][[1t[?{Table Name}]]].value\](" style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 12px; color: #3163f7;")}}{&simple} What is going on (to replicate elsewhere): 1. Start the command with a bang (!) so that it is an API message 2. Include {&simple} somewhere so that at the end the message is sent to chat 3. Use .value to extract the value of the actual roll (peg it right up against the closing double brackets) 4. Use deferrals to delay the detection of the button brackets until after the value has been extracted from the roll. Deferral looks like this: [\] ... \]
1666881021
The Aaron
Roll20 Production Team
API Scripter
The fundamental issue is how Roll20 expands Rollable Tables in the context of a link.  To get around that, you'll need to have the roll expanded by the Mod, or use a Mod Script to generate the formatted output to begin with.
The styling for each item needs to be in the table, not in the macro you are using to roll on the table. You can see an example of that here . Your macro will look like this: !rt &{template:npcaction} {{rname=?{Table Name}}} {{description=[[1t[?{Table Name}]]]}} And the item on your rollable table will look like this: [An Ornate Brooch of Dwarven Design](" style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 12px; color: #3163f7;") I would strongly recommend setting the whole thing up in an Excel table and using Table Export  to generate your list of table items.
1666912317

Edited 1666912687
Tara
Pro
timmaugh said: Another option would be to use ZeroFrame to extract the value from the inline roll: !&{template:npcaction} {{rname=?{Table Name}}} {{description=[\][[1t[?{Table Name}]]].value\](" style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 12px; color: #3163f7;")}}{&simple} What is going on (to replicate elsewhere): 1. Start the command with a bang (!) so that it is an API message 2. Include {&simple} somewhere so that at the end the message is sent to chat 3. Use .value to extract the value of the actual roll (peg it right up against the closing double brackets) 4. Use deferrals to delay the detection of the button brackets until after the value has been extracted from the roll. Deferral looks like this: [\] ... \] This seems to be conflicting with the Macro Mule API  and throwing an error I have no desire to troubleshoot atm (mainly because I have yet to take the time to even learn the API syntax). That might be a project for the future, but for now, I think I'm going to try Jarren's suggestion. Thanks though! I'll definitely keep this on the backburner.
Tara said: timmaugh said: Another option would be to use ZeroFrame to extract the value from the inline roll: !&{template:npcaction} {{rname=?{Table Name}}} {{description=[\][[1t[?{Table Name}]]].value\](" style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 12px; color: #3163f7;")}}{&simple} What is going on (to replicate elsewhere): 1. Start the command with a bang (!) so that it is an API message 2. Include {&simple} somewhere so that at the end the message is sent to chat 3. Use .value to extract the value of the actual roll (peg it right up against the closing double brackets) 4. Use deferrals to delay the detection of the button brackets until after the value has been extracted from the roll. Deferral looks like this: [\] ... \] This seems to be conflicting with the Macro Mule API  and throwing an error I have no desire to troubleshoot atm (mainly because I have yet to take the time to even learn the API syntax). That might be a project for the future, but for now, I think I'm going to try Jarren's suggestion. Thanks though! I'll definitely keep this on the backburner. It's highly likely  that the Macro Mule script is written poorly and should get modified to not interfere with timmaugh's metascripts... not the other way around!  I'm pretty sure I've got things included incorrectly in the on("ready") function or something.
1667001830

Edited 1667001888
Tara
Pro
Jarren said: It's highly likely  that the Macro Mule script is written poorly and should get modified to not interfere with timmaugh's metascripts... not the other way around!  I'm pretty sure I've got things included incorrectly in the on("ready") function or something. So the MM is interfering with RecursiveTable mod. If I've already got the MM set up and I just need it running for the !self functionality, can I just get rid of everything except if('api'===msg.type && /^!self(\b\s|$)/i.test(msg.content)){... }  inside  on("chat:message",function(msg){...} along with the constants above it?
OK, I've reduced the script to this: const scriptName = "CreateMacroMule"; const version = '2.0';  const mmName = 'MM'; on("ready",setTimeout(function(){   on("chat:message",function(msg){       if('api'===msg.type && /^!self(\b\s|$)/i.test(msg.content)){         const args = msg.content.split(/\s+/);         const who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname');         var content = args.slice(1).join(' ');           if(_.has(msg,'rolltemplate') && _.isString(msg.rolltemplate) && msg.rolltemplate.length){               content = content.replace(/\{\{/,'&{template:'+msg.rolltemplate+'} {{');           }           if(1 === args.length) {               return;           } else {               sendChat(`${who}`,`/w "${who}" ${content} `);           }           return;                 }    })   log(`-=> ${scriptName} script enabled v${version} <=- Macro Mule Name is: ${mmName}`); },0)) The !self functionality still works, but it is also still interfering with RecursiveTable
I found the solution - I removed the setTimeout 
I think the issue might be with the "setTimeout(function()" portion, which I was attempting to incorporate from this thread . I think I missed part of the syntax, so hopefully this will fix it:  const scriptName = "CreateMacroMule"; const version = '2.0';  const mmName = 'MM'; on('ready',setTimeout(()=>{   on("chat:message",function(msg){       if('api'===msg.type && /^!self(\b\s|$)/i.test(msg.content)){         const args = msg.content.split(/\s+/);         const who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname');         var content = args.slice(1).join(' ');           if(_.has(msg,'rolltemplate') && _.isString(msg.rolltemplate) && msg.rolltemplate.length){               content = content.replace(/\{\{/,'&{template:'+msg.rolltemplate+'} {{');           }           if(1 === args.length) {               return;           } else {               sendChat(`${who}`,`/w "${who}" ${content} `);           }           return;                 }    })   log(`-=> ${scriptName} script enabled v${version} <=- Macro Mule Name is: ${mmName}`); },0));
hmmmm....arrow functions are functionally identical to their explicit counterparts as far as I know - but I tried it anyway and it failed - it's still preventing recursiveTables from functioning. I've just removed the setTimeout for now. I skimmed through that link and it looks like it won't affect anything until i hit my 19th mod, so I guess - I'll burn that bridge when I get to it (but if you do find the solution in the meantime, by all means, feel free to let me know)