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

Handout Generator

1603832290

Edited 1603832361
I found this awesome API (courtesy of former user Shannon P ) that allows a player to generate a handout by chatting "!handout" and I was wondering - is there a way to get it to also generate the contents of a handout? I have an idea for something I'd like to do in game that would necessitate being able to add text inside the handout when it generates.&nbsp; on('ready',function(){ &nbsp; "use strict"; &nbsp; on('chat:message',function(msg){ &nbsp; &nbsp; var player,handout; &nbsp; &nbsp; if('api' === msg.type &amp;&amp; msg.content.match(/^!handout/) ){ &nbsp; &nbsp; &nbsp; &nbsp; player=getObj('player',msg.playerid); &nbsp; &nbsp; &nbsp; &nbsp; if(player){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; handout=createObj('handout',{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: 'Handout for '+player.get('displayname'), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inplayerjournals: "all", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; controlledby: (playerIsGM(msg.playerid) ? '' : msg.playerid) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat('','/w "'+player.get('displayname')+'" Created a handout for you: &lt;a href="<a href="http://journal.roll20.net/handout/'+handout.id+" rel="nofollow">http://journal.roll20.net/handout/'+handout.id+</a>'" style="color:blue;text-decoration:underline;"&gt;Handout for '+player.get('displayname')+'&lt;/a&gt;'); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } &nbsp; }); });
1603832742
The Aaron
Roll20 Production Team
API Scripter
The answer is "yes". on('ready',function(){ "use strict"; on('chat:message',function(msg){ var player,handout; if('api' === msg.type &amp;&amp; msg.content.match(/^!handout/) ){ player=getObj('player',msg.playerid); if(player){ handout=createObj('handout',{ name: 'Handout for '+player.get('displayname'), inplayerjournals: "all", controlledby: (playerIsGM(msg.playerid) ? '' : msg.playerid) }); handout.set('notes',"Some bunch of text from somewhere."); sendChat('','/w "'+player.get('displayname')+'" Created a handout for you: &lt;a href="<a href="http://journal.roll20.net/handout/'+handout.id+" rel="nofollow">http://journal.roll20.net/handout/'+handout.id+</a>'" style="color:blue;text-decoration:underline;"&gt;Handout for '+player.get('displayname')+'&lt;/a&gt;'); } } }); });
1603834087

Edited 1603839045
Okay, so I made a few adjustments that I thought were innocuous enough, but this causes the entire script to stop working. That said, I don't get an error message, so I don't know what I'm doing wrong. Help?&nbsp; on('ready',function(){ "use strict"; on('chat:message',function(msg){ var player,handout; if('api' === msg.type &amp;&amp; msg.content.match(/^!handout/) ){ player=getObj('player',msg.playerid); if(player){ handout=createObj('handout',{ name: ' Secret Message ', inplayerjournals: +player.get('displayname'), controlledby: (playerIsGM(msg.playerid) ? '' : msg.playerid) }); handout.set('notes',"This is a secret message."); sendChat('','/w "You found a &lt;a href="<a href="http://journal.roll20.net/handout/'+handout.id+" rel="nofollow">http://journal.roll20.net/handout/'+handout.id+</a>'" style="color:blue;text-decoration:underline;"&gt;Secret Message+'&lt;/a&gt;'); } } }); }); Edit: I've been finagling with it and it seems to be working now, though the change I made now seems to generate it without granting anyone the ability to view or edit the handout. I'm fine with the latter, but it needs to be seen (only) by the player that generates it. Right now, I'm using &nbsp; inplayerjournals: (playerIsGM(msg.playerid) ? '' : msg.playerid) &nbsp;but I'm guessing that's not right.&nbsp; Edit Edit: Nvm. Rejoined the game as player and the handout works as intended.
1603887923
The Aaron
Roll20 Production Team
API Scripter
Great!