ID:143996
 
Code:
obj
Computer
verb
Use_Computer()
set src in oview(1)
if(!usr.pcuname)
usr << "<font color = blue>Welcome to Windows: Space edition! The censors say you do not have an account. Please create one."
usr.pcuname = input("Please select an account name.","Pick account.",usr.pcuname)
usr << "<font color = blue>Congratulations! Your account name is now [usr].[usr.pcuname]."
usr << "<font color = blue>Now you need a password.</font>"
switch(alert("Do you want to make a password or set to random?","Password","Make a custom password","Give me a random one"))
if("Make a custom password")
usr.pcpass = input("Please enter a password.","Pick password.",usr.pcpass)
usr.memory+="<font color = blue>Your PC password is '</font><font color = green>[usr.pcpass]'"
usr << "<font color = blue>You have set your password and it was added to your memory!"
if("Give me a random one")
usr.pcpass = rand(151,6243)
usr.memory+="<font color = blue>Your PC password is </font>'[usr.pcpass]'"
usr << "<font color = blue>You have set your password and it was added to you memory!"
else
usr << "<font color = blue>The censors say you have an account...Please wait a moment till we find it for you..."
sleep(rand(5,50))
usr << "<font color = blue>Your account is [usr].[usr.pcuname]. Please enter your password for added security."
usr.pcepass = input("Enter password","Password")
if(usr.pcepass==usr.pcpass)
usr << "<font color = blue>You have succesfully logged in!"
sleep(5)
usr << "<font color = blue>Now logging onto the internet. Please wait a moment."
usr << browse("Connecting to the internet...","window=connect")
sleep(rand(5,40))
usr << browse(null,"window=connect")
usr.Internet()
else
usr << "<font color = red>You made an error while entering your password. Please check you memory and make sure you entered it correctly."
usr.pcepass = null
icon = 'comp.dmi'
icon_state = "comp"


Problem description:
Now, when they use the random password thing, if they enter the correct password, it won't work...

Revojake wrote:
Code:
usr.pcpass = rand(151,6243) //This is where you should fix it, I'll explain why...
usr.pcepass = input("Enter password","Password") //This is inputing a character string although when you compare it here...
if(usr.pcepass==usr.pcpass) //You are comparing an integer between 151 and 6243 to the temp string called pcepass

//My fix
usr.pcpass = num2text(rand(151,6243))


Good luck with your game!

-KirbyAllStar

In response to KirbyAllStar (#1)
usr.pcepass = input("Enter password","Password") as text
// this should automatically turn the return of the input into a text string, so you don't have to turn the number into one specifically when it's in use
In response to Keeth (#2)
You didn't understand me... The pcpass is a number, the pcepass is a string, since the pcpass should always be a string anyways why not change it, not sure but I don't think that way would work.

-KirbyAllStar
In response to KirbyAllStar (#3)
Keeth's post is pointless as input()'s default type is 'as text' at any case, and it will obviously not change anything. At any case it looks like he just quickly posted without thinking about it.
You can have it done in 2 ways; you need to compare both values, so they need to be in the same format. You can either have their both converted to nums or both as text - it matters not, either way will do.

However, you are missing the point; the random number, pcpass, will be returned as a number. You should just use input()'s data type filter 'as num', which will already make pcepass also a num.
In response to Kaioken (#4)
But if the user puts their own password in it will most likely not be just numbers. Like my password may be "blah123yay" that most certainly isn't all numbers so the "as num" would make that case invalid.

-KirbyAllStar
In response to KirbyAllStar (#5)
However the true password will always be a number anyway, so no use letting them enter text.
You may say that the players don't know that and might try to guess text passwords and whatnot, but anyway sooner than later they'll see that passwords are numeric only.
In response to Kaioken (#6)
So if you used "as num" with the input, you could input whatever you wanted and compare it to another value that has been retrieved with another input with "as num" and it would be valid no matter the input? Hope that makes sense.

-KirbyAllStar
In response to KirbyAllStar (#1)
I liked your idea the most, Kirby.
obj
Computer
verb
Use_Computer()
set src in oview(1)
if(!usr.pcuname)
usr << "<font color = blue>Welcome to Windows: Space edition! The censors say you do not have an account. Please create one."
usr.pcuname = input("Please select an account name.","Pick account.",usr.pcuname)
usr << "<font color = blue>Congratulations! Your account name is now [usr].[usr.pcuname]."
usr << "<font color = blue>Now you need a password.</font>"
switch(alert("Do you want to make a password or set to random?","Password","Make a custom password","Give me a random one"))
if("Make a custom password")
usr.pcpass = input("Please enter a password.","Pick password.",usr.pcpass)
usr.memory+="<font color = blue>Your PC password is '</font><font color = green>[usr.pcpass]'"
usr << "<font color = blue>You have set your password and it was added to your memory!"
if("Give me a random one")
usr.pcpass = num2text(rand(151,6243))//Here it is...
usr.memory+="<font color = blue>Your PC password is </font>'[usr.pcpass]'"
usr << "<font color = blue>You have set your password and it was added to you memory!"
else
usr << "<font color = blue>The censors say you have an account...Please wait a moment till we find it for you..."
sleep(rand(5,50))
usr << "<font color = blue>Your account is [usr].[usr.pcuname]. Please enter your password for added security."
usr.pcepass = input("Enter password","Password")
if(usr.pcepass==usr.pcpass)
usr << "<font color = blue>You have succesfully logged in!"
sleep(5)
usr << "<font color = blue>Now logging onto the internet. Please wait a moment."
usr << browse("Connecting to the internet...","window=connect")
sleep(rand(5,40))
usr << browse(null,"window=connect")
usr.Internet()
else
usr << "<font color = red>You made an error while entering your password. Please check you memory and make sure you entered it correctly."
usr.pcepass = null
icon = 'comp.dmi'
icon_state = "comp"

Did I do it in the wrong spot? It doesn't work.
In response to Revojake (#8)
Are you sure your inputing the right numbers? It worked when I did that, I'm going to test it again.

[EDIT] This is exactly what I tested it with...
mob/var
memory
pcpass
pcuname
pcepass
obj
Computer
verb
See_mem()
set src in oview(1)
usr << usr.memory
Use_Computer()
set src in oview(1)
if(!usr.pcuname)
usr << "<font color = blue>Welcome to Windows: Space edition! The censors say you do not have an account. Please create one."
usr.pcuname = input("Please select an account name.","Pick account.",usr.pcuname)
usr << "<font color = blue>Congratulations! Your account name is now [usr].[usr.pcuname]."
usr << "<font color = blue>Now you need a password.</font>"
switch(alert("Do you want to make a password or set to random?","Password","Make a custom password","Give me a random one"))
if("Make a custom password")
usr.pcpass = input("Please enter a password.","Pick password.",usr.pcpass)
usr.memory+="<font color = blue>Your PC password is '</font><font color = green>[usr.pcpass]'"
usr << "<font color = blue>You have set your password and it was added to your memory!"
if("Give me a random one")
usr.pcpass = num2text(rand(151,6243))//Here it is...
usr.memory+="<font color = blue>Your PC password is </font>'[usr.pcpass]'"
usr << "<font color = blue>You have set your password and it was added to you memory!"
else
usr << "<font color = blue>The censors say you have an account...Please wait a moment till we find it for you..."
sleep(rand(5,50))
usr << "<font color = blue>Your account is [usr].[usr.pcuname]. Please enter your password for added security."
usr.pcepass = input("Enter password","Password")
if(usr.pcepass==usr.pcpass)
usr << "<font color = blue>You have succesfully logged in!"
sleep(5)
usr << "<font color = blue>Now logging onto the internet. Please wait a moment."
usr << browse("Connecting to the internet...","window=connect")
sleep(rand(5,40))
usr << browse(null,"window=connect")
// usr.Internet()
else
usr << "<font color = red>You made an error while entering your password. Please check you memory and make sure you entered it correctly."
usr.pcepass = null
icon = 'comp.dmi'
icon_state = "comp"


-KirbyAllStar
In response to KirbyAllStar (#9)
Thanks, I just forgot a small var.
In response to KirbyAllStar (#7)
Hmm? Well, yes.
What I'm saying is that for you to compare a number like that, you have to make sure you're comparing the same values, as you know, comparing "5" to 5 will return false because it isn't the same; one is a text string with the character 5 and another is an actual number.

Our var, usr.pcpass (which I don't think should be defined on the mob anyway, Revojake tends to do that) is set to a NUMERIC value, rand() returns a number. So if you set 'pcepass' to an input() with 'as num', that input() will only allow to enter numbers, and that input() will return a numeric value*(or null). So then both the 'pcpass' and 'pcepass' variables contain numbers, so you can compare them successfully.