AC Tool Forums

# .Random Between 5-20 Number

## Recommended Posts

Hey there, how can i random between 5 and 20 ?

##### Share on other sites

Call Random 5,20
Procedure Random using LO, HI
Timestamp Get Number
Compute Number = INT((\$HI - \$LO + 1) * rnd(1) + \$LO)
Timestamp \$Number
End

Constants
Number = 0
End

The Timestamp \$Number is the result.

##### Share on other sites

I'm missing something here, and driving me nuts. Getting old and cannot remember things

I'm trying to make the numbers between 1 and 4 including decimal points, eg 1.4 or 2.3 etc.

My game has a anti bot pop up window, so I'm changing the way the cool-down timer works to stop the code from being the exact time every cool-down.

Below is what I have, open to suggestions. It's got to be simple, I just can't see it yet.

Procedure Random using LO, HI
loop 100 // remove when fixed.
Timestamp Get Number
Compute Number = INT((\$HI - \$LO + 1) * rnd(1) + \$LO)
Timestamp \$Number // CoolDown Timer
End // remove when fixed.
End

##### Share on other sites

Ego, the way you have it coded. It will only return the Integer value of a random number instead of the decimal value. So, it will always return a value of 2.

All you need to do is change one line to the following:

`compute Number = (\$HI-\$LO+1)*rnd(1)+\$LO`

##### Share on other sites

Thanks WABBIT, fixed that little annoyance. I used Call Random 1,3 as it goes as high as 3.999-.

Perfect.

Call Random 1,3
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Procedure Random using LO, HI
compute Number = (\$HI-\$LO+1)*rnd(1)+\$LO
Timestamp \$Number
End
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

##### Share on other sites

I keep getting :

Error: Constant NUMBER could not be found!

Module: new.mac   Line:4

Which is the compute Number = (\$HI-\$LO+1)*rnd(1)+\$LO line.

What am i missing?

##### Share on other sites

Helps if you put up your code so we can look thru it.

Error: Constant NUMBER could not be found!

Constants

Number = 0

End

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×

• #### Activity

• Tutorials
×
• Create New...