ID:273113
 
I know how to randomly generate numbers (obviously :P), but letters are a different story.
I'm trying to make a password-like sequence that's randomly generated for doors (the owner of the door will be told the sequence, however).

It'll generate numbers and letters, but for the life of me I dunno how to do the latter.
Simplest way: md5() the person key, and maybe the world.time as well to make it unique.


Harder way:
. = ""
for(var/i = 1 to LENGTH_OF_PASS_YOU_WANT)
.+=ascii2text() <-- search up values for lower/uppercase letters and/or number.
world << "Password is [.]"
Pretty much what GhostAnime said but I just wanted to write my own :)

#define ALPHA 1
#define NUM 2

#define ALPHA_NUM ALPHA | NUM

mob
verb
Test()
world << Generate(ALPHA_NUM, 30)


proc
Generate(bitflag, length)
.=""
for(var/i = 1; i <= length; i++)
if(bitflag&ALPHA && !(bitflag&NUM))
. += "[ascii2text(pick(rand(65, 90), rand(97, 122)))]"
else if(bitflag&NUM && !(bitflag&ALPHA))
. += "[rand(1,9)]"
else if(bitflag&ALPHA_NUM)
. += "[Generate( pick(ALPHA, NUM), 1 )]"


That's the first time I've ever recursively called a procedure that I've created, not sure if I'm doing it right, am I?
In response to Metamorphman
Metamorphman wrote:
Gonna jump on the bandwagon.
http://www.byond.com/members/jtgibson/forum?id=277

That's it, I had a faint memory of me creating something similar to this. Wow, I did with incredible failure :S