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

Script request or guidance.

1624630624

Edited 1624630734
I am looking to see if there is already a script made that I can run that gives me a command that when entered allows me to add text to the GM notes field on a selected token?   Case use: I have a random npc generator.  I already do amazing stuff with tokenmod but I want to attach traits/bonds/personality/flaws/voice notes to the token when the script fires but I'm hard pressed to think of how to do this.  I can't fit more then 2 additional notes into the unused bar values.  I thought supernotes would do it but that just reads them to me, it doesn't let me input them.  Its a trap does a similar action but it doesn't mesh with what I need.  I have all the rollable tables set I just need a script that lets me write their results into a gmnote.   EDIT:  I should preface that I already use the setup manually in that when I fire my random npc generator instead of editing the gmnote field it whispers me the results into a chat field and then I just paste that into the notes, but I was wondering if I could pull a script that does it for me, I guess it would need to be able to handle the rollable table syntaxs.  
1624630961
The Aaron
Roll20 Production Team
API Scripter
Just so I'm clear, you want to run a bunch of script commands, which result in a chat message output, then have a script that takes that output and stuffs it into the gm notes of a token?
What I am essentially looking for is an api script that just simply lets me type something like !editnotes "something" and when the selected tokens DM notes is opened "Something" is in that note.  It also needs to be able to take the syntax of rolling tables though cause I'm going to be putting [[1t[NPCQuirk]]] into that note.  I dunno if thats an issue, I know that some scripts can't handle the extra brackets and thats why you made recursive tables.  
Tokenmod does like 99% of this macro already perfectly and awesomely, but I'm just trying to clean up the chatlog spam from it and save a cut and paste.  
1624636272

Edited 1624636403
!token-mod  --set  imgsrc|[[1t[NPCFemaleImage]]]  name|"[[1t[NPCFemaleFirstName]]] [[1t[NPCLastName]]]" /w gm  Voice=[[1t[NPCVoice]]] | Quirks = [[1t[NPCQuirk]]], [[1t[NPCQuirk]]], [[1t[NPCQuirk]]] I want the /w gm to be replaced with something like supernotes only the reverse, instead of it outputting to chat, I want what is in that line entered into the dm notes of the selected token.  Edit:  But it needs to be able to express the results of those tables so that the notes say the results instead of those exact characters.  
1624636430
The Aaron
Roll20 Production Team
API Scripter
I have this snippet which lets you write to or append to the GMNotes on Token or Character, or the Bio on Character: on('ready',function(){ 'use strict'; const cmdregex=/^(!(?:set|add)-(?:c?gmnote|bio))\s*/, formatMsg = (c)=>c.replace(cmdregex,'').replace(/(^{{\s*|\s*}}$)/gm,''); on('chat:message',function(msg){ if('api' === msg.type) { let match=msg.content.match(cmdregex); if(match && playerIsGM(msg.playerid) ){ let content = formatMsg(msg.content), who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); if(_.has(msg,'inlinerolls')){ content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ var ti=_.reduce(v.results.rolls,function(m2,v2){ if(_.has(v2,'table')){ m2.push(_.reduce(v2.results,function(m3,v3){ m3.push(v3.tableItem.name); return m3; },[]).join(', ')); } return m2; },[]).join(', '); m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },content) .value(); } if(content.length){ let tokens = _.chain(msg.selected) .map( s => getObj('graphic',s._id)) .reject(_.isUndefined) ; switch(match[1]){ case '!set-gmnote': tokens.each( o => { o.set({ gmnotes: content }); }); break; case '!set-cgmnote': tokens.map( o => getObj('character',o.get('represents'))) .reject(_.isUndefined) .each( o => { o.set({ gmnotes: content }); }); break; case '!set-bio': tokens.map( o => getObj('character',o.get('represents'))) .reject(_.isUndefined) .each( o => { o.set({ bio: content }); }); break; case '!add-gmnote': tokens.each( o =>{ o.set({ gmnotes: `${o.get('gmnotes')}<br>\n${content}` }); }); break; case '!add-cgmnote': tokens.map( o => getObj('character',o.get('represents'))) .reject(_.isUndefined) .each( o => { o.get('gmnotes',(notes)=>{ _.defer(()=>o.set({ gmnotes: `${notes}<br>\n${content}` })); }); }); break; case '!add-bio': tokens.map( o => getObj('character',o.get('represents'))) .reject(_.isUndefined) .each( o => { o.get('bio',(notes)=>{ _.defer(()=>o.set({ bio: `${notes}<br>\n${content}` })); }); }); break; } } else { sendChat('',`/w "${who}" <div>`+ `<div>Use <code>COMMNAD Some Text</code> or <code>COMMAND {{ some multi-line text}}</code>.</div>`+ `<div><b>Commands:</b></div>`+ `<div><ul>`+ `<li><code>!set-gmnote</code> -- Replaces contents of token gmnotes.</li>`+ `<li><code>!set-cgmnote</code> -- Replaces contents of character gmnotes.</li>`+ `<li><code>!set-bio</code> -- Replaces contents of character bio.</li>`+ `<li><code>!add-gmnote</code> -- Appends to contents of token gmnotes.</li>`+ `<li><code>!add-cgmnote</code> -- Appends to contents of character gmnotes.</li>`+ `<li><code>!add-bio</code> -- Appends to contents of character bio.</li>`+ `</ul></div>` ); } } } }); }); It will expand inline rolls, including tables.  You could combine it with RecursiveTable to get some more complicated behavior. Use  COMMNAD Some Text  or  COMMAND {{ some multi-line text}} . Commands: !set-gmnote  -- Replaces contents of token gmnotes. !set-cgmnote  -- Replaces contents of character gmnotes. !set-bio  -- Replaces contents of character bio. !add-gmnote  -- Appends to contents of token gmnotes. !add-cgmnote  -- Appends to contents of character gmnotes. !add-bio  -- Appends to contents of character bio.
You are a miracle worker!  Thank you so much!
1624637957
The Aaron
Roll20 Production Team
API Scripter
No problem! =D