How Do I make one flag that checks if:
is_valid_length, is_valid_letters, is_valid_digits, is_valid_at
are all true? also How Do I make it only Display correct at the end and not you must follow the rules at the end. if i take put "output_msg ="You must follow these rules";" then output_msg becomes an unknown variable. Someone help me please and thankyou
{
var is_valid_length, is_valid_letters, is_valid_digits, is_valid_at, output_msg;
is_valid_length = false;
is_valid_letters = false;
is_valid_digits = false;
is_valid_at = false;
var user;
var length,char;
length = 0;
char = 0;
do{
output_msg ="You must follow these rules";
user=get_string("Enter password:","")
if (string_length(user)>=6 && string_length(user)<=10){
is_valid_length = true;
}
else{
output_msg =("Password is not 5-10 characters long");
}
if (string_length(string_digits(user))>=1){
is_valid_digits = true;
}
else{
output_msg +=("#Password Does not contain 1 digit");
}
if (string_length(string_letters(user))>=1){
is_valid_letters = true;
}
else{
output_msg +=("#Password Does not contain 1 letter");
}
if (string_count('@',user)>=1){
is_valid_at=true;
}
else{
output_msg +=("#Password Does not contain @");
}
show_message(output_msg);
if (is_valid_length && is_valid_letters && is_valid_digits && is_valid_at ==true) {
show_message("correct");
}
}
until
is_valid_length = true;
is_valid_letters = true;
is_valid_digits = true;
is_valid_at = true;
}
Well I can answer part of your question. To make one expression to evaluate all of your boolean you would do:
if (is_valid_length && is_valid_letters){
if (is_valid_digits && is_valid_at){
show_message("correct");
}
}
I don't think game maker allows for more than one && or ||. You do not need the == true part because just typing them in will evaluate them. If you did something like:
if (!is_valid_length){}
The ! symbol is evaluating to see if it is NOT true.
As for your second question, the reason output_msg is an unknown variable is because you were deleting the declaration of output_msg.
to make it only display "correct" put an else on the end of your 4 boolean checks like this:
if (is_valid_length && is_valid_letters){
if (is_valid_digits && is_valid_at){
show_message("correct");
}
}
else show_message(output_msg);
I would do the whole block like this:
var output_msg;
var is_valid_length = false;
var is_valid_letters = false;
var is_valid_digits = false;
var is_valid_at = false;
var all_true = false; //variable for all true
var user;
var length,char;
length = 0;
char = 0;
do{
output_msg ="You must follow these rules";
user=get_string("Enter password:","")
if (string_length(user)>=6 && string_length(user)<=10){
is_valid_length = true;
}
else{
output_msg +=("#Password is not 5-10 characters long");
is_valid_length = false; //resetting if they get it wrong second try
}
if (string_length(string_digits(user))>=1){
is_valid_digits = true;
}
else{
output_msg +=("#Password Does not contain 1 digit");
is_valid_digits = false;
}
if (string_length(string_letters(user))>=1){
is_valid_letters = true;
}
else{
output_msg +=("#Password Does not contain 1 letter");
is_valid_letters = false;
}
if (string_count('@',user)>=1){
is_valid_at=true;
}
else{
output_msg +=("#Password Does not contain @");
is_valid_at=false;
}
if (is_valid_length && is_valid_letters){
if (is_valid_digits && is_valid_at){
show_message("correct");
all_true = true; //exits out of do loop
}
}
else {
show_message(output_msg);
all_true = false;
}
}
until all_true == true;
Hope this helps