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 table and links to handouts

Is it possible to have the output of a roll table point to a journal entry?   I have roughly 20 random encounters that are described in individual handouts.  I would like to create a roll table that has a link to the handout.  This way I can simply roll on the table, click the link to the journal, and have all of the information I need in front of me.  Is this possible?  I tried various incarnations to try to get links to appear, but it seems like it really only spits out text. I know that I can create one giant macro that essentially does this, but I was hoping it might be simpler.
1479401228
The Aaron
Pro
API Scripter
Probably not without an API script. &nbsp;You could store the handout id as the value of the roll and try a construct like: [Encounter Details](<a href="http://journal.roll20.net/handout/[[" rel="nofollow">http://journal.roll20.net/handout/[[</a> 1t[Encounters] ]]) But I don't think that will work right because of the formatting of inline rolls.
1479403275

Edited 1479403294
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
The Aaron said: Probably not without an API script. &nbsp;You could store the handout id as the value of the roll and try a construct like: [Encounter Details](<a href="http://journal.roll20.net/handout/[[" rel="nofollow">http://journal.roll20.net/handout/[[</a> 1t[Encounters] ]]) But I don't think that will work right because of the formatting of inline rolls. See Silvyre's post here . You need to make an unmatched inline roll, so changing the above to be: [Encounter Details [[]( <a href="http://journal.roll20.net/handout/[[" rel="nofollow">http://journal.roll20.net/handout/[[</a> 1t[Encounters] ]]) will force the inline roll to be parsed as text. This will not parse the text of the table entry, though, it will parse the number that the table resolves to. You can use the tinyurl method detailed in that thread to get around this though.
The Aaron said: Probably not without an API script. &nbsp;You could store the handout id as the value of the roll and try a construct like: [Encounter Details](<a href="http://journal.roll20.net/handout/[[" rel="nofollow">http://journal.roll20.net/handout/[[</a> 1t[Encounters] ]]) But I don't think that will work right because of the formatting of inline rolls. I tried this, however it doesn't work as expected. &nbsp;I think that you are correct, even inline rolls aren't really interpreted in a way that the link can be expanded correctly, because I think the actual inline rolls come back as (-journalid).
1479405693
The Aaron
Pro
API Scripter
All ids in Roll20 begin with a -. &nbsp;(It's actually an off by one or "fence post" error in the guid calculation code. =D)
Scott C. said: See Silvyre's post here . You need to make an unmatched inline roll, so changing the above to be: [Encounter Details [[]( <a href="http://journal.roll20.net/handout/[[" rel="nofollow">http://journal.roll20.net/handout/[[</a> 1t[Encounters] ]]) will force the inline roll to be parsed as text. This will not parse the text of the table entry, though, it will parse the number that the table resolves to. You can use the tinyurl method detailed in that thread to get around this though. Not sure I follow. &nbsp;When using the unmatched inline brackets, I do see the output of "[Encounter Details ][[(<a href="http://journal.roll20.net/handout/0" rel="nofollow">http://journal.roll20.net/handout/0</a>)" which 0 is the entry (I currently only have one table entry, so 0 makes sense). &nbsp;I don't understand the tinyurl method enough to get that. Linking handouts is so helpful, but it feels like it is only partially implemented... there is no way have a token or image link to a handout, there is no way to include a handout link in a roll table... It makes trying to keep the entire campaign in Roll20 more challenging than it should be when you can only link handouts in certain areas, but not others.
1479414018

Edited 1479415888
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Just realized you have a pro subscription. I'd recommend using&nbsp; Recursive Tables for this, a side effect of it expanding the text of the table entry is that it allows you to put embedded links directly into the table results.
1479415326
The Aaron
Pro
API Scripter
Ah, good call! !rt /w gm [Encounter Details](<a href="http://journal.roll20.net/handout/[[" rel="nofollow">http://journal.roll20.net/handout/[[</a> 1t[Encounters] ]]) Should whisper you a link provided your rollable table is setup right.
1479415833
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Could also just do !rt [[1t[Encounters] ]] and have each table entry be in the format: [Short Description of encounter](link to handout)
1479416784

Edited 1479417144
The Aaron said: Ah, good call! !rt /w gm [Encounter Details](<a href="http://journal.roll20.net/handout/[[" rel="nofollow">http://journal.roll20.net/handout/[[</a> 1t[Encounters] ]]) Should whisper you a link provided your rollable table is setup right. This does indeed work, it's not exactly what I was hoping for, but I think I can make it work. &nbsp;Actually Recursive Tables solves a different problem that I have with random encounters as well.
Scott C. said: Could also just do !rt [[1t[Encounters] ]] and have each table entry be in the format: [Short Description of encounter](link to handout) This is exactly what I was hoping for... now if I can get it into a roll template, will be all set!
1479417943
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Recursive tables currently can either respect slash commands (e.g. /w gm) or roll templates, but not both (and roll templates override slash commands). There's a fix in the wings though. *nudge nudge Aaron* :)
So this is almost exactly what I was hoping for... when I attempt to put it into a Roll Template (obviously not required, but keeps things neat and organized), I can't get it to honor the "/w gm" portion of the command. &nbsp;Here is how it looks: The words "Barovian Commoners" links as expected to the handout describing the encounter, so that part is awesome (along with expanding the number). Any idea why the /w gm portion wouldn't work?
1479418209
The Aaron
Pro
API Scripter
Thinking about it, this sounds a bit tedious... How about this: !random-journal [ path] Picks a random entry from the specified folder path in the journal and gives a link to it: !random-journal Test/Encounters Omitting the path means it grabs one from the root of the journals. &nbsp;Works for characters and handouts, so just build your folders appropriately. &nbsp;This version just whispers to the GM, but you can expand on it I'll wager. =D&nbsp; Code: on('ready',function(){ &nbsp; &nbsp; 'use strict'; &nbsp; &nbsp; on('chat:message',function(msg){ &nbsp; &nbsp; &nbsp; &nbsp; if('api' === msg.type && msg.content.match(/^!random-journal/) && playerIsGM(msg.playerid) ){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let path=msg.content.replace(/^!random-journal\s*/,''), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; journals=JSON.parse(Campaign().get('journalfolder')), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; obj = findObjs({ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id: _.chain(path.split('/')) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .reject(_.isEmpty) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .reduce((m,p)=&gt;(_.filter(m,(o)=&gt;_.isObject(o) && o.n===p)[0]||{i:[]}).i, journals) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .reject(_.isObject) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .sample() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .value() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })[0]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(obj){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat('RandomJournal',`/w gm &lt;a style="text-decoration:underline;padding: .1em .5em; border-radius: .5em;display:inline-block;border:1px solid #ccc;background-color:#eee;" href="<a href="http://journal.roll20.net/${obj.get('type')}/${obj.id}&quot;&gt;${path.length" rel="nofollow">http://journal.roll20.net/${obj.get('type')}/${obj.id}"&gt;${path.length</a> ? `&lt;b&gt;${path}&lt;/b&gt;: `:''}${obj.get('name')}&lt;/a&gt;`); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat('RandomJournal', `/w gm &lt;b&gt;Error:&lt;/b&gt; No journal entries found in &lt;code&gt;${path||'[Root]'}&lt;/code&gt;.`); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; }); });
1479418259
The Aaron
Pro
API Scripter
Yeah, Scott has fixed that for me and I just need to roll it out... =D
1479419861
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
How are you getting the folder structure for the handouts? I thought that was totally inaccessible.
1479420029
The Aaron
Pro
API Scripter
You can read code! It's on Campaign. _journalfolder "" A JSON string which contains data about the folder structure of the game. Read-only. It's not inaccessible, it's read only.
1479420103
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hah, I can read code, I'm apparently just too lazy and blind to correctly read it.
1479420190
The Aaron
Pro
API Scripter
I gotta say, I'm pretty proud of that path traversal code... &nbsp;=D
I like the random journal option, I will need to play around with it. &nbsp;I might be able to change the journal entries around a bit to make it work and it's a pretty elegant solution.