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] Random Encounter Table Help

1483592690

Edited 1483592851
Hi everyone, I'm brand new to the API and starting to familiarize myself with JS.  I've been working on a script to roll on a random encounter table.  Here's the gist of it: Check for encounter (1 on 1d6) Check encounter type (Roll 1d20, 1-10 is a location, 11-20 is a monster) Check for tracks (Tracks found if 1d100 roll < Tracks value from table) Check for lair (Lair found if 1d100 roll < Lair value from table) No tracks or lair?  Then encounter wandering monster. Here's the  code . My issue is down in the if/then statements where I'm determining if an encounter is tracks/a lair/a monster.  I want these expressions to be evaluating the Lair and Tracks values of the table entry selected by resolveMessage.  I didn't know how to do that and so right now resolveTracks and resolveLair is rolling on the table all over again (providing inconsistent results, of course). I lack the JS knowledge to figure this out.  Can someone help me with a method to return the Lair and Tracks values from the table entry selected by resolveMessage? Thank you!
Very simply, you could call your resolveTracks and resolveLair functions from within your resolveMessage function and return the three results as one by doing "return {message: resolved_message, lair: resolved_lair, tracks: resolved_tracks}"
Thank you!  After a little tooling around, I got it to  work .