Accumulate Score on a random number.

Hello.

I need help. How can I get the score to accumulate on a random number?

Here is the code below:

[[start]]:
@set p1_score = 0

getRndInteger = function(min,max){
    return Math.floor(Math.random()*max)+min;
};

Hello.

get a random integer

var rndInt = getRndInteger(0,2);
set("int",rndInt);
Your random integer is: {int}.

Player 1's Score: {p1_score}
{RESULT}

get a random integer

[[RESULT]]:
{if int=0: {RES00} }
{if int=1: {RES01} }

[[RES00]]:
You missed the shot.

[[RES01]]:
@inc p1_score 2
You made a two pointer.


K.V.

Something like this?

[[start]]:
    getRndInteger = function(min,max){
        return Math.floor(Math.random()*max)+min;
    };
@set p1_score=0

Hello.

[get a random integer]



Player 1's Score: {p1_score}


[get a random integer]:
    var rndInt = getRndInteger(0,2);
    set("int",rndInt);
Your random integer is: {int}.


{if int=0: {RES00} }
{if int=1: {RES01} }

[[RES00]]:
You missed the shot.

[[RES01]]:
{@p1_score+=2}

You made a two pointer.

Player 1's Score: {p1_score}

This will work out just fine. Thanks!!


K.V.

I made a two pointer!


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

Support

Forums