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 .
×

GiGs Universal Chat Menus

1775682234

Edited 1775682282
In an attempt to find out ways to deal with old friends who are computer hostile and/or illiterate, LOL, I posted  here  and got a wonderful suggestion of using the method outlined here at [Script, Call For Testers] Universal Chat Menus by GiGs . For some reason, I'm having trouble with it. Vince posted an example which is exactly what I was looking to do. I took the code in the second post by Gigs, and copied it to a new module. Everything was copied and saved. I then grabbed the macro code suggestions by Vince but I could not get Gigs' Chat Menu to work. I used some logs to see where GiGs' script was going and it seemed to be processing when called by Vince's macros. The logs were placed in locations under: if ('api' === msg_orig.type && msg_orig.content.toLowerCase().startsWith('!chatmenu ')) and it looks like the logs were triggered. The final log at the end of the above routine fires twice. Here's a screen shot of my console and I've circled two attempts: The code of one of Vice's macros is shown here along with a character selected: I'm not the brightest bulb when it comes to API script, but I'm wondering if anyone can suggest where I might have gone wrong?  -- Tim
1775683085
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
What character sheet are you using? Each UCM macro is extremely sheet specific, and unless it was thoroughly reworked very recently, the script absolutely will not work with any Beacon-based sheet.
If the log is showing that it is being posted twice, the first thing to check is if you inadvertently added the script twice. Can you post a screenshot of the Mod API script page?  The second thing to check is if you inadvertently copied and pasted the code twice in the same script block.  Can you also confirm which character sheet you have selected for the game? You can see that on the Game Settings page under the ' Character Sheet Template' heading. Or you can post a screenshot from any character in the game.
keithcurtis said: What character sheet are you using? Each UCM macro is extremely sheet specific, and unless it was thoroughly reworked very recently, the script absolutely will not work with any Beacon-based sheet. Vince's AD&D 1e sheet. He suggested weapon and equipment macros using GiGs' Chat menu. :)
1775689532

Edited 1775690281
Jarren said: If the log is showing that it is being posted twice, the first thing to check is if you inadvertently added the script twice. Can you post a screenshot of the Mod API script page?&nbsp; The second thing to check is if you inadvertently copied and pasted the code twice in the same script block.&nbsp; Can you also confirm which character sheet you have selected for the game? You can see that on the Game Settings page under the ' Character Sheet Template' heading. Or you can post a screenshot from any character in the game. HI Jarren, the full script is on the second post of: <a href="https://app.roll20.net/forum/post/7474530/script-call-for-testers-universal-chat-menus/?pageforid=7474530#post-7474530" rel="nofollow">https://app.roll20.net/forum/post/7474530/script-call-for-testers-universal-chat-menus/?pageforid=7474530#post-7474530</a> I copied that exactly. The area where I put the comments is below. I've added logs and a couple of them I have commented out. Note, I've changed all my log messages to be prefixed by "Tim - " as GiGs has his own commented out logs throughout his script. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ('api' === msg_orig.type &amp;&amp; msg_orig.content.toLowerCase().startsWith('!chatmenu ')) { let msg = _.clone(msg_orig); let args = processInlinerolls(msg).split(/\s+--/); // get character and heading let parameters = args[0].split(/\s+/); const cid = parameters[1] || ''; //character id // log("Tim - Start of Chatmenu process"); if (cid === '') { sendChat(scriptName, 'No recognised character.'); // log("Tim - No recognised character 1"); return; } const who = getAttrByName(cid, 'character_name'); if (!who) { sendChat(scriptName, 'No recognised character.'); // log("Tim - No recognised character 2"); return; } // log("Tim - Past first 2 IFs"); const sender = 'character|' + cid; const caller = (getObj('player', msg.playerid) || { get: () =&gt; 'API' }).get('_displayname'); let header = parameters.slice(2).join(' ') || defaultHeader(who); // if this starts with {template: it is a rolltemplate // and if it contains CHATMENU, the menu buttons are placed there. Otherwise they are placed at the end. // get buttons let combineSections = false; // if false, defaultTemplate sections; if true, combine all sections into one args.shift(); let buttons = buildButtons(cid, who, args); log("Tim - Let Buttons"); // buttons will be an object, each item key is a section title, and each item value is an array of buttons in that section // build chat menu buttons if (buttons.hasOwnProperty('error')) { sendChat(scriptName, buttons['error'].toString()); return; } log("Tim - Past buttons.hasOwnProperty error"); let headerPrint = `&amp;{template:default}{{name=${header}}}`; if (header.includes('template:')) { headerPrint = `&amp;${header}`; } headerPrint = headerPrint.replace(/(\[)/g, '[[').replace(/(\])/g, ']]'); // make sure no inline rolls present log("Tim - Past make sure no inlinerolls"); let footer = extractFrom(buttons, 'footer', ''); let separator = extractFrom(buttons, 'separator', SEPARATOR); let output = ''; let sections = Object.keys(buttons); if (headerPrint.includes(MENUPLACE)) combineSections = true; for (let section of sections) { if (buttons[section].length &gt; 0) { output += (combineSections ? `**${section.toUpperCase()}**\n` : `{{**${section}**=`); output += buttons[section].join(separator); output += (combineSections ? `\n` : `}}`); } } let print = combineSections ? headerPrint.replace(MENUPLACE, output) : headerPrint + output; print += footer ? `\n/w ${caller} ${footer}` : ''; sendChat(sender, `/w ${caller} ${print}`,null,{noarchive:true}); log("Tim - Past sendChat(sender, `/w ${caller} ${print}"); } log("Tim - chatmenu process complete");
1775720087

Edited 1775720178
vÍnce
Pro
Sheet Author
I can verify that this macro; !chatmenu @{selected|character_id} {template:general} {{color=@{selected|color_option}}} {{name=@{selected|character_name}}} {{subtag=Chat Menu}} {{freetext=CHATMENU}} --title:Weapons --repeating_weapon|weapon_name|weapon_attack_roll works as expected with the 1e sheet and it only posts once (UNLESS there are 2 copies of the universalChatmenus script in the API mods as Jarren mentioned...) Oddly enough, I was not getting 2 copies of the output in chat yesterday when I originally posted my examples for Tim, but when I tested the weapons macro just now, I did get 2 copies.&nbsp; WTH?&nbsp; I checked my loaded API mods and there were 2 copies of universalChatMenu.js in my mods.&nbsp; I'm 99% sure I only copied and saved one version of GiGs mod yesterday and my posted image from yesterday; shows I was only getting 1 output per macro.&nbsp; Somehow the script ended up being saved twice in my mods list. No idea how that happened. I deleted one of them and script works as expected.&nbsp; Double check your mods Tim.&nbsp; There might be a doppelganger.&nbsp;
1775744044
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I'm not sure if this is still a bug, but rapid restarts of the sandbox (particularly a small one) can create brief interludes where there are two concurrent sandboxes running. It usually doesn't persist for more than a few seconds.