Help for a beginner: Random number generators

So, I'm starting out with squiffy. I'd like to be able to create text based games, even just for myself to enjoy recreationally. To get used to the program I've made several test games to experiment with the different things Squiffy can do, but I'm at a hitch. You see, I'm experimenting with odds for any random events I'd like to do in future. And for the life of me, I can't figure out how to do it. I'm not very familiar with javascript. Please, help me out if you can.

Welcome to the forum!

This example might help you:

     var randomnumber = function rng(min, max) {
     return Math.floor(Math.random() * (max - min) + min);

    set ("random_event", randomnumber(1,5));

You're walking through a dense forest. 

Soon, you enter a deep ravine.

[[Continue through the ravine]](Ravine)


{if random_event=1: *A spider appears!*}
{if random_event=2: *An orc appears!*}
{if random_event=3: *You narrowly avoid some falling stones!*}
{if random_event=4: *Nothing happens.*}

Thank you very much, Valgardur. This community seems fantastic. It took a bit of fanagling, mostly me simply putting in the wrong syntax, but I got it working. A few friends of mine were scratching our heads over this all afternoon.

Personally, I would suggest Quest....
Lots more options, and (I think) easer to learn.

Yeah its fun to experiment - specially when you finally get something right. :)

DarkLizerd: Quest is probably easier to learn, but Squiffy is almost limitless once you get the hang of it. It won't serve you solutions though, so you really need to crunch everything yourself.

This topic is now closed. Topics are closed after 60 days of inactivity.