using "ElseIf" in text entry box scripts...

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

using "ElseIf" in text entry box scripts...

Postby Suicune » Wed May 05, 2010 1:46 pm

ok so i need help again, i know how to make text entry boxes work, but ive never made one that had 2 "answers" before, and now that ive tried to experiment, it has failed and i keep getting a "syntax error"... so can someone please help fix this script for me?

If TextBoxObject(16).Text <> "CORRECT PASSWORD" Then
Message "Login failed!"
ElseIf
TextBoxObject(16).Text <> "EGG PASSWORD" Then
Action.GoToFrame "computer wrong screen"
Message "Login failed!"
Else
Action.GoToFrame "computer screen 2"
Message "Login successful!"
End If


it works just fine without the middle "ElseIf" part, but i want that there because i got a humorous "egg" screen that you can get to if you enter something in particular, that the player will likely fall for.

i tried replacing the <> with = but that didnt seem to cure the "syntax error", any ideas?
Suicune
Member
 
Posts: 29
Joined: Fri Dec 25, 2009 2:59 pm

Postby juhuwoorps » Wed May 05, 2010 1:56 pm

I'm not sure if this is what you want but try it out:

Code: Select all
If TextBoxObject(16).Text <> "CORRECT PASSWORD" Then
Message "Login failed!"
End If
If
TextBoxObject(16).Text <> "EGG PASSWORD" Then
Action.GoToFrame "computer wrong screen"
Message "Login failed!"
Else
Action.GoToFrame "computer screen 2"
Message "Login successful!"
End If
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby Suicune » Wed May 05, 2010 2:08 pm

thanks for trying, but that doesnt seem to be working. im not sure if this text box script can support having more than 1 "if" to it, mabye thats why it wont work.
Suicune
Member
 
Posts: 29
Joined: Fri Dec 25, 2009 2:59 pm

Postby juhuwoorps » Wed May 05, 2010 2:34 pm

Do you also get a syntax error with this code? if so please post the error message.
What script are you using?
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby Suicune » Wed May 05, 2010 2:45 pm

juhuwoorps wrote:Do you also get a syntax error with this code? if so please post the error message.
What script are you using?


yes, i also get a syntax error with the script that you gave me. here is a screenshot of what it says:

Image

then, after hitting "OK" this next screen pops up:

Image

as for "what script are you using", i dont know what you mean, isnt all adventure maker script VBScript?
Suicune
Member
 
Posts: 29
Joined: Fri Dec 25, 2009 2:59 pm

Postby juhuwoorps » Wed May 05, 2010 3:34 pm

Ok. Can you please explain what to do at each statement?

I think that the problem is that you are using two times <>

I would try something like this:

If TextBoxObject(16).Text = "CORRECT PASSWORD" Then
Message "CORRECT PASSWORD!"
Action.GoToFrame "computer screen 2"
else
Message "Login failed!"
End If
if
TextBoxObject(16).Text = "EGG PASSWORD" Then
Message "here the code for what to do when egg password"
end if
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby Mystery » Wed May 05, 2010 4:09 pm

Yes, I think the problem is that you are using twice <> (not equal to).

Do you also get the error message with this?

Code: Select all
If TextBoxObject(16).Text = "CORRECT PASSWORD" Then
  Message "CORRECT PASSWORD!"
  Action.GoToFrame "computer screen 2"
ElseIf TextBoxObject(16).Text = "EGG PASSWORD" Then
  Action.GoToFrame "computer wrong screen"
  Message "Login failed!"
Else
  Message "Login failed!"
End If
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Suicune » Wed May 05, 2010 4:12 pm

ok i tried it, but it still gives me a syntax error (the same error i posted above)

if i remove the second if part at the end though, it works, but then of course, the whole "fake answer" thing is blown to ~~didn't mean to swear~~. so the problem doesnt seem to be the <> command, since the script works equally with that, or with = providing there is only 1 "if" in it.

but it does seem like having 2 "if" commands is the issue here. i wonder if theres a way around it?

"can you please explain what to do at each statement":

well, if you mean explain each line of the script...

the 1st "if" is supposed to be the correct answer that takes the player to the next screen.

the 2nd "if" is meant to be the "egg" and if they enter that particular password, they get to the "fake" next screen.

the "else" is what triggers the "login failed" text to appear, to let the player know they entered an invalid password, besides the egg one.

the "message"s are just text messages that get displayed, and im sure the problem cant be there.

the "action.gotoframe"s are obviously just to tell the game what frame to load next. and each of the 2 "if"s would have a different frame to go to.

hope that helps explain the issue i seem to be having
Suicune
Member
 
Posts: 29
Joined: Fri Dec 25, 2009 2:59 pm

Postby Suicune » Wed May 05, 2010 4:18 pm

Mystery wrote:Yes, I think the problem is that you are using twice <> (not equal to).

Do you also get the error message with this?

Code: Select all
If TextBoxObject(16).Text = "CORRECT PASSWORD" Then
  Message "CORRECT PASSWORD!"
  Action.GoToFrame "computer screen 2"
ElseIf TextBoxObject(16).Text = "EGG PASSWORD" Then
  Action.GoToFrame "computer wrong screen"
  Message "Login failed!"
Else
  Message "Login failed!"
End If


wow this one seems to be working! thanks mystery! :D

but, the 2 equal signs werent the only problem apparently, because when i did that with juhus script i was still getting a syntax error. when i tried putting 2 <> commands on YOUR script though, it gave me a completly DIFFERENT error. so there was another problem after all. comparing all the scripts mentioned, i think the problem was that i had the "gotoframe" command backwards, being in the else command instead of the 1st if.

anyways thanks it seems to work fine now, i just tested it out.
Suicune
Member
 
Posts: 29
Joined: Fri Dec 25, 2009 2:59 pm

Postby Mystery » Wed May 05, 2010 4:25 pm

Great that it works now, you're welcome :)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests

cron