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

Rolling values on loot table. Recursive Tables

Hello Everyone, I am having an issue with the API RecursiveTable. My goal is to have a loot rollable table. Whenever the rollable table is used it will land on an item and generate say 1d4 of that item. I tried the API and for some reason the value output I get is always 0. I am not sure if this is due to the fact of the newest update to Roll20 or if the script is just really old. Does anyone have an idea how a value can be automatically generated for a random item on a rollable table?
1676580456
The Aaron
Roll20 Production Team
API Scripter
Hi Nate.  Can you show the command you're using to run RecursiveTable?  Also, what other scripts are you using?  I just tracked down an issue earlier this week where Vampire the Masquerade was causing this issue (I sent a pull request to fix it).
After messing around with it. I was able to spot the conflict. Whenever "Simple Sound" API is enabled, that is when the problem occurs. I was using the command !rt [[1t[Random-Scraps-Common(CR-1-4)]]], with  Random-Scraps-Common(CR-1-4) being the rollable table. As long as "Simple Sound" is disabled the script works fine.
1676581621
The Aaron
Roll20 Production Team
API Scripter
Excellent, I'll go fix that script and get a pull request set up.  Here's a fixed version if you want to use it until the pull request is taken: /** * simplesound.js * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * The goal of this script is to play/stop sound effects from the Roll20 Jukebox * via commandline. * * Syntax: * * !splay [sound name] - play the named sound effect * !sstop [sound name] - stop the named sound effect * !swhisper - toggle the GM whisper status * !sstop - stop all tracks currently playing * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Revison History: * * 0.2.0 - Added the !swhisper command to endable/disable whispers via command * 0.2.1 - Modified !sstop to stop all tracks with no variable * */ var simpleSound = simpleSound || (function(){ 'use strict'; var playSound = function(trackname, action) { var track = findObjs({type: 'jukeboxtrack', title: trackname})[0]; if(track) { track.set('playing',false); track.set('softstop',false); if(action == 'play'){ track.set('playing',true); } } else { sendChat('Simple Sound Script', '/w gm No Track Found...'); log("No track found "+trackname); } }, stopAllSounds = function() { var tracks = findObjs({type: 'jukeboxtrack', playing: true}); if(tracks) { _.each(tracks, function(sound) { sound.set('playing', false); }); } }, handleInput = function(msg_orig) { let msg = _.clone(msg_orig); var whispers = state.simpleSound.whisper; if ( "api" !== msg.type ) { return; } if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ m['$[['+k+']]']=v.results.total || 0; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },msg.content) .value(); } if(msg.content.indexOf("!splay") !== -1 ) { var args = ["!splay", msg.content.replace('!splay','').trim()] } else if(msg.content.indexOf("!sstop") !== -1) { var args = ["!sstop", msg.content.replace('!sstop','').trim()] } else if(msg.content.indexOf("!swhisper") !== -1) { var args = ["!swhisper".trim()] } else { return; } if (! state.simpleSound.whisper){state.simpleSound.whisper = false;} switch(args[0]) { case '!splay': { var track_name = args[1] || 0; if(track_name) { if(whispers){ sendChat('Simple Sound Script', '/w gm <b>[PLAYING]</b> ' + track_name); } playSound(track_name,'play'); } else { sendChat('Simple Sound Script', '/w gm Syntax: !splay [track name]'); } break; } case '!sstop': { var track_name = args[1] || 0; if(track_name) { if(whispers){ sendChat('Simple Sound Script', '/w gm <b>[STOPPING]</b> ' + track_name); } playSound(track_name,'stop'); } else { if(whispers){ sendChat('Simple Sound Script', '/w gm <b>[STOPPING ALL TRACKS]</b>'); } stopAllSounds(); } break; } case '!swhisper': { if(state.simpleSound.whisper == true) { state.simpleSound.whisper = false; } else { state.simpleSound.whisper = true; } var whispers = state.simpleSound.whisper; sendChat('Simple Sound Script', '/w gm Whispers are set to ( <b>' + whispers + '</b> )'); break; } } }, checkInstall = function() { var script_version = "0.2.1"; if( ! state.simpleSound ) { state.simpleSound = { version: script_version, whisper: false, }; } if (! state.simpleSound.whisper){state.simpleSound.whisper = false;} if (state.simpleSound.version != script_version) state.simpleSound.version = script_version; log("-=> Simple Sound Script v"+state.simpleSound.version+" Initialized <=-") }, registerEventHandlers = function() { on('chat:message', handleInput); }; return { CheckInstall: checkInstall, RegisterEventHandlers: registerEventHandlers }; }()); on("ready", function() { 'use strict'; simpleSound.CheckInstall(); simpleSound.RegisterEventHandlers(); });
Both scripts working as intended now. Thanks!
1676582341
The Aaron
Roll20 Production Team
API Scripter
Great!  I sent the pull request, so some time next week or the week after, the version the Script Library should be updated.