Variable Question

I have set a variable to return a random number between 1 and 6 (die roll) in the first section of a game. I tried to display X in a second section but the number did not display.

[[room]]:
var X = Math.ceil(Math.random() * 6); // random number between 1 and 6
squiffy.set("X",X);
You have rolled the die. [[next]]

[[next]]:
X is now {X}


K.V.

Hello.

Be sure to add 4 spaces in front of the JS:

[[room]]:
    var X = Math.ceil(Math.random() * 6); // random number between 1 and 6
    squiffy.set("X",X);
You have rolled the die. [[next]]

[[next]]:
X is now {X}

This works for me.


Thanks.
Turns out I had a typo in the actual game file.

There is more elaborate calculating I am trying to learn in order to compare player{ X} and an NPC {Y} values, do a die roll against the difference and compare the results. The NPC {Y} would not be a randomly generated value.

For example, I want to do something like {if X>Y:You win!}{else:You lose.}

I'm going to keep poking through the forums to find some good examples that I can use.


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

Support

Forums