Variable Question
J_H_Bailey
05 Mar 2018, 00:53I 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}
![](https://i.imgur.com/mBf7TBeb.png)
K.V.
05 Mar 2018, 04:28Hello.
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.
J_H_Bailey
05 Mar 2018, 05:19Thanks.
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.