Help for a beginner: Random number generators

SomeDClass
18 Feb 2019, 19:58

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.
http://textadventures.co.uk/squiffy/editor?id=-3MaM_UMW0C498LkEg2Zjg


Valgardur
18 Feb 2019, 22:13

Welcome to the forum!

This example might help you:

[[Start]]:
     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)

[[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.*}


SomeDClass
19 Feb 2019, 00:25

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.


DarkLizerd
19 Feb 2019, 03:15

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


Valgardur
20 Feb 2019, 10:02

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.