Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Question About Random (https://forums.graalonline.com/forums/showthread.php?t=13652)

MrCoolDude 10-03-2001 03:49 AM

Question About Random
 
Can random be used with letters somehow? Ex:
PHP Code:

Random(a,z

That doesn't work, is there another way to do this? Maybe Stefan should make the command work with letters as well as numbers.

nyghtGT 10-03-2001 03:51 AM

Re: Question About Random
 
Quote:

Originally posted by MrCoolDude
Can random be used with letters somehow? Ex:
PHP Code:

Random(a,z

That doesn't work, is there another way to do this? Maybe Stefan should make the command work with letters as well as numbers.

yeah but there is a command for it but i am not sure what it is ....

entravial 10-03-2001 03:51 AM

~AlphaFlame~

Of course that doesn't work if you're talking about variables. You're asking it for a random from a to z, not the value of variable a to variable z. That would be

random(#v(a),#v(b))

I believe.

grim_squeaker_x 10-03-2001 03:53 AM

It cannot be used with letters unless you use some special scripting, E.G this:
NPC Code:
if (playertouchsme) {
this.i=int(random(0,26));
message #e(this.i,1,abcdefghijklmnopqrstuvwxyz);
}


And AlphaFlame, random is a function which uses variables so it doesn't need the #v

btedji 10-03-2001 03:54 AM

you could make a string 26 characters long with the alphabet, then use the random for 1 through 26 and do a part string with that number

btedji 10-03-2001 03:55 AM

it seems i posted a little too slow :)

btedji 10-03-2001 03:57 AM

Quote:

Originally posted by grim_squeaker_x
It cannot be used with letters unless you use some special scripting, E.G this:
NPC Code:
if (playertouchsme) {
this.i=int(random(0,26));
message #e(this.i,1,abcdefghijklmnopqrstuvwxyz);
}


And AlphaFlame, random is a function which uses variables so it doesn't need the #v

you can make this shorter:

NPC Code:

if (playertouchsme) {
message #e(int(random(0,26)),1,abcdefghijklmnopqrstuvwxyz) ;
}



not much shorter but better

nyghtGT 10-03-2001 03:57 AM

so ....
 
Quote:

Originally posted by entravial
~AlphaFlame~

Of course that doesn't work if you're talking about variables. You're asking it for a random from a to z, not the value of variable a to variable z. That would be

random(#v(a),#v(b))

I believe.

so if i used:
NPC Code:

if (created)
setstring testing,random(#v(a),#v(z));
message #s(testing);
}


A letter between A and Z might appear ?

btedji 10-03-2001 04:04 AM

or you could do this:

NPC Code:

if (created) {
setstring testing,#e(int(random(0,26)),1,abcdefghijklmnopqrs tuvwxyz);

message #s(testing);
}


entravial 10-03-2001 04:34 AM

~AlphaFlame~

My apologies then, btedji. I personally don't use variables with random... too much trouble really.

And yes, use btedji's letter script. It works. Though I can't see why you need a random letter...

IceHawk 10-03-2001 05:21 AM

can make it a random hole number then assign all letters to a #
like
1 = a
2 = b
etc.

grim_squeaker_x 10-03-2001 05:56 PM

Quote:

Originally posted by Kaimetsu
I'm surprised nobody has realised the correct way to do this yet.

#K

Just another way of doing it, and it's far harder to make any random sequence of letters possible with using #K.

dragoonvenganc 10-03-2001 09:03 PM

then kammy why not just tell the person who asked how to do it with #k... instead of saying all you rejects #k is better...

Shard_IceFire 10-03-2001 09:14 PM

Quote:

then kammy why not just tell the person who asked how to do it with #k... instead of saying all you rejects #k is better...
We know he can script it, it's just a matter of whether or not he'll post it.

btedji 10-04-2001 03:06 AM

Quote:

Originally posted by Shard_IceFire

We know he can script it, it's just a matter of whether or not he'll post it.

there never was a good description of #k

MrCoolDude 10-05-2001 06:37 AM

Ok, thanks for the help everyone...I'll have to mess around with #K sometime.


All times are GMT +2. The time now is 02:19 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.