```
var coin = Math.ceil(Math.random() *2 );
squiffy.set("coin", coin);
var dice = Math.ceil(Math.random() *6 );
squiffy.set("dice", dice);
{if coin=1:{@coinside=heads}}{if coin=2:{@coinside=tails}}
Your coinflip resulted in {coinside}, and your die rolled a {dice}.
```

Of course, what Squiffy SHOULD be able to do is

{random coin:heads:tails}

Maybe some day.

`var coin = Math.ceil(Math.random() *2 );`

Better to put:

```
squiffy.set("coin", (Math.random() > 0.5) ? 'heads' : 'tails');
```

then you don't need all the `if`

line.

Of course, what Squiffy SHOULD be able to do is

{random coin:heads:tails}

That doesn't seem intuitive. Maybe something like…

```
@set coin = {{random:heads:tails:}}
```

it would be easy enough to make that work… like 4 lines added to the Squiffy source.

Unfortunately, not so easy to implement within a game.

Squiffy already uses the format I presented with rotate.

For example,

{rotate meats:beef:pork:chicken:mutton: venison}

So it would be consistent.

Good point.

I think I can see how to do it now, but doing it without modifying the Squiffy source will be awkward because of some functions that user code can't access directly.

Log in to post a reply.