mIRC Home    About    Download    Register    News    Help

Print Thread
#66869 07/01/04 12:07 AM
Joined: Sep 2003
Posts: 120
G
Gar Offline OP
Vogon poet
OP Offline
Vogon poet
G
Joined: Sep 2003
Posts: 120
I was wondring, I am trying to get four number between 1-6 and want to drop the lowest number. Any hints on how I do this? I know how to get the random numbers, using the $rand thing, but how can I drop the lowest?

#66870 07/01/04 12:24 AM
Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Code:
$deltok($sorttok($eval($str($!rand(1,6) $+ $chr(32),4),2),32,n),1,32)

#66871 07/01/04 12:50 AM
Joined: Sep 2003
Posts: 120
G
Gar Offline OP
Vogon poet
OP Offline
Vogon poet
G
Joined: Sep 2003
Posts: 120
Thanks. Is there a way of presenting it in this fashion:

#1 + #2 + #3 + #4 = (sum of three highest #)

Is this possible?

#66872 07/01/04 01:02 AM
Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
I didn't really understand what you want. In any case, the key part of the solution is $sorttok() which allows you sort the numbers. Then you can drop the 1st number in the list, which is the lower too. So, something like:
Code:
tokenize 32 $sorttok($eval($str($!rand(1,6) $+ $chr(32),4),2),32,n)
$1 + $2 + $3 + $4 = $calc($2 + $3 + $4)

#66873 07/01/04 01:40 AM
Joined: Sep 2003
Posts: 120
G
Gar Offline OP
Vogon poet
OP Offline
Vogon poet
G
Joined: Sep 2003
Posts: 120
okay with this code:

Code:
alias statbuy {
  msg # $sorttok($eval($str($!rand(1,6) $+ $chr(32),4),2),32,n)$1 $2 $3 $4 = $calc($2 + $3 + $4)
}


I got this in four tries:

<Gararion> 1 2 3 4 = 0
<Gararion> 1 4 4 5 = 0
<Gararion> 1 4 4 6 = 0
<Gararion> 2 3 4 6 = 0

What I wanted was this:

<Gararion> 1 2 3 4 = 9
<Gararion> 1 4 4 5 = 13
<Gararion> 1 4 4 6 = 14
<Gararion> 2 3 4 6 = 13

Is this better explained? Note that my additons only add the last three numbers, those being the hieghest numbers.

#66874 07/01/04 03:53 AM
D
DaveC
DaveC
D
try...
Code:
 
alias statbuy {
  tokenize 32 $sorttok($eval($str($!rand(1,6) $+ $chr(32),4),2),32,n)
  msg # $1 $2 $3 $4 = $calc($2 + $3 + $4)
}


My Personal ^5 to Querty for the great method of getting the 4 random numbers, ill use that myself for things from now on.

#66875 07/01/04 04:34 AM
Joined: Sep 2003
Posts: 120
G
Gar Offline OP
Vogon poet
OP Offline
Vogon poet
G
Joined: Sep 2003
Posts: 120
Thanks, that worked


Link Copied to Clipboard