How to use a rand commando in a comparative


#1

I want that the player chose a number between 1 100 and compare it to a rand die_roll but don’t work what I’m doing wrong

*input_number number 1 100
*rand die_roll 1 100
*if die_roll > {number} ____bla \*elseif die_roll = {number}
____ble
*else
____bli

I have to put ()? I really confused about how do this please help!


#2

If you want to compare two values, there’s no need for the ${}. To use your example:


*input_number number 1 100 
*rand die_roll 1 100 
*if die_roll > number
    bla 
*elseif die_roll = number
    ble 
*else 
    bli 

That should work.


#3

but I want people input the name themselves @CS_Closet or with the number alone work?
edit I think I understand know I have to set number “$” before don’t I ?


#4

I don’t think you need the “$” at all. “input_number number 1 100” works like using the *set command, but the player can type in the value. The only thing you need to do is make sure “number” and “die_roll” are variables in the mygame.js.


#5

yes are variables


#6

I have not tried this but I would code it this way


Choose a number 1 thru 100
\*input_text number
\*rand die_roll 1 100
\*if (die_roll > number)
 Bla
\*elseif (die_roll = number)
 Ble
\*else
 Bli

#7

thanks I think work fine for now!!