Undum - random numbers and hidden text?

So I’ve just put together my first, fairly simple IF project using the Undum platform, and given my limited knowledge of Javascript I kept it fairly simple. It’s fine as it is, but there’s one link I’d ideally like to be able to hide and only reveal on a random basis, say on a one out of three chance each time the situation is visited. I can see that Undum has a random number generator built in, but I’m not sure how I’d use it to selectively add a bit of text and a link to the end of a situation on a random basis…any chance anyone could point me in the right direction on this? Thanks!

You can use the enter method to catch when the situation is entered and then apply the randomness methods:

corridor: new SimpleSituation( "<p>You are in a dark corridor.</p>", { enter: function( character, system, from ) { if( system.rnd.randomInt( 1, 3 ) === 1 ) { system.write( "<p>You hear <a href='sound'>a suspicious sound</a>.</p>" ); } else { system.write( "<p>It's quiet... Too quiet.</p>" ); } } });
Another possibility is system.rnd.random() which produces a random number between 0 and 1 that’s useful when working with percentages, e.g. if( system.rnd.random() < 0.15 ) to get a 15% probability. (These are documented here: undum.com/API.html#h_31)

That worked great! Thanks so much.