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

Create a Macro for deck

Hello, is it possible to create a macro for displaying the deck in the macro bar ? Thanks
1617292273
The Aaron
Roll20 Production Team
API Scripter
I believe so.  I've never actually messed with it, but it appears to be the 'shown' property on the deck, which is writable.
OK how must i do to activate it please ?
1617306387
The Aaron
Roll20 Production Team
API Scripter
If you're writing the API script, you'll need to get the deck object somehow, then call .set() on it. deck.set('shown',true); If you're not writing the API script... Here's one: !toggle-deck Some Deck Name or Fragment code: on('ready',()=>{ const keyFormat = (s)=>s.toLowerCase().replace(/[^a-z0-9]/g,''); const getDecks = (name) => { let deckKey=keyFormat(name||''); return deckKey ? _.filter(findObjs({ type: 'deck' }), (d)=> -1 !== keyFormat(d.get('name')).indexOf(deckKey)) : []; }; on('chat:message',msg=>{ if('api'===msg.type && /^!toggle-deck(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let tokens = (msg.selected || []) .map(o=>getObj('graphic',o._id)) .filter(g=>undefined !== g) ; let deckname = msg.content.replace(/^!toggle-deck\s*/,''); let decks = getDecks(deckname); if(!deckname.length){ sendChat('',`/w "${who}" <div>Usage: <code>!toggle-deck NAME</code></div>`); return; } _.each(decks, (d)=>{ d.set('shown',!d.get('shown')); }); } }); });
OK thanks but it's too complicated for me The deck's name is Fouille i tried but i didn't manage thanks
1617307764
The Aaron
Roll20 Production Team
API Scripter
You'd just need to put that code in a tab of your API Scripts, then you can call: !toggle-deck Fouille
Great it works  i love it thanks a lot
1617370181
The Aaron
Roll20 Production Team
API Scripter
No problem! =D