Checking if Multiple Statements are True

Hello. I'm trying to make a fake login page for my Squiffy game. I want to make it so that the game will check if both untry=username and pwtry=password are true. If they are, the game takes them to the homepage. If they aren't, text appears telling the player "Invalid Credentials" then returns them to the login page.

This is my code for that event:

{if [email protected]:{if [email protected]:[[HELLO, WORLD...]](homepage)}{else:Invalid Credentials. Return to [[login]] and try again.}}{else:Invalid Credentials. Return to [[login]] and try again.}

I thought I was being really big brain with this one. Guess not cause it ain't working.


{if [email protected]:[[HELLO, WORLD...]](homepage)}{else:Invalid Credentials. Return to [[login]] and try again.}

That works just fine. But I wanted to check BOTH values.


Are you sure that the attributes untry and pwtry contain the text @username and @password respectively? If could be failing because of an extra space somewhere, or something like that.

How are you setting those attributes? Have you tried displaying them to make sure they contain what you expect?


Not sure what you mean by that first sentence, mrangel, but i used @username and @password to call upon the attribute. It works when I'm calling just one, like {if [email protected]:[[HELLO, WORLD...]](homepage)}.

One attribute shows up as intended here:

[[homepage]]:

@clear
###### Not Secure | livenet.com/homepage/user?id=N-OrlsTICEGEtgyjHoLVRg

[[Log Out]](login)

# Welcome back, {username}!

This is when username and password are set:

[[first]]:

## Login to join millions others!

Username
<input type="text" id="username"/>
<p>Password
<input type="text" id="password"/>

<p>
#### [[Go]](new section)

[[new section]]:

squiffy.set("username", jQuery("#username").val());
squiffy.set("password", jQuery("#password").val());
setTimeout(function(){ squiffy.story.go("homepage");}, 2000);

HELLO, WORLD...

For when untry and pwtry are set:

[[login]]:

## Login to join millions others!

Username
<input type="text" id="untry"/>
<p>Password
<input type="text" id="pwtry"/>

<p>
#### [[Go]](auth)

[[auth]]:

squiffy.set("untry", jQuery("#untry").val());
squiffy.set("pwtry", jQuery("#pwtry").val());

I did see a thread about something similar, so that was I tried, but it didn't work.

http://textadventures.co.uk/forum/squiffy/topic/a0fzuidemkimyn_hhmeibw/checking-two-attributes-for-conditions


OK, I keep on trying that, and it seems to be working.

But, when you say it's not working, what do you mean?
Does it show the else condition when you entered the right details?
Does it let you in when it shouldn't?
Does it just display nothing?


no matter what i put the second time, it shows nothing


OK… I pasted your code into a new game, with a couple of dummy pages in between, and it works fine for me (except for the link to [[auth]] not appearing… but that doesn't sound like the problem you're having, so I won't bother investigating that further)

Can you show a game that demonstrates this problem?


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums