How to create a textbox to let the player type in a password

This forum is meant for people to share their knowledge by writing their own tutorials for Adventure Maker.

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

How to create a textbox to let the player type in a password

Postby Mystery » Mon Dec 03, 2007 9:50 am

I've been asked how such a puzzle works, therefore I've decided to make a thread about it for everyone to use. Of course you can adapt this example to your own needs.

Create for example a door, and make a hotspot over the door knob. Don't forget to add also a hotspot that the player can click to leave the screen.

Open the Frame Properties and go to the Advanced Tab. Enter the script:
Code: Select all
LoadControl TextBoxObject(1)
TextBoxObject(1).Move 240*15,300*15,300*15,30*15
TextBoxObject(1).Visible = True


To change the position and size of the textbox, replace the values in the above code according to LEFT*15,TOP*15,WIDTH*15,HEIGHT*15. To figure out the correct values may take some playing around.

Then open the Hotspot Properties of the hotspot over the doorknob, go to the Advanced tab and enter (in this example "Guard" is the correct password):

Code: Select all
If TextBoxObject(1).Text <> "Guard" Then
   Message "The password seems to be wrong."
Else
   Action.GoToFrame "FrameName"
End If


Please note that you need to unload the textbox object on all screens where the player can go after that (for example the screen where the player goes after entering the correct password; and the screen where the player goes when he/she leaves the screen without entering the correct password), otherwise the textbox will be displayed on all the following screens.
So for each screen where the player might go next, open the Advanced Tab of the Frame Properties (or the Advanced Tab of the Hotspot Properties of the hotspot that the player clicks to leave the screen), and enter:

Code: Select all
UnloadControl TextBoxObject(1)


To add more similar puzzles, just change the number of your TextBoxObjet. The next one would be TextBoxObject(2).

Let me know if anything is not clear :)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Candle » Mon Dec 03, 2007 9:54 am

Please don't PM me questions, ask here in the forums!
``````````````
Between grand theft and a legal fee, there only stands a law degree.
User avatar
Candle
Administrator
 
Posts: 3051
Joined: Sat Feb 07, 2004 2:21 am
Location: Rudy's Bar

Postby Mystery » Mon Dec 03, 2007 9:56 am

Yes, it's very similar, but in this example the player can enter something in a textbox instead of a pop-up message box.
It's also very good for pc passwords for example. :)
Last edited by Mystery on Mon Dec 03, 2007 10:01 am, edited 1 time in total.
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Candle » Mon Dec 03, 2007 10:00 am

That would be called an edit box then. so yes yours is better .
I have been wondering how to do that too.
Thanks much for it :)
Please don't PM me questions, ask here in the forums!
``````````````
Between grand theft and a legal fee, there only stands a law degree.
User avatar
Candle
Administrator
 
Posts: 3051
Joined: Sat Feb 07, 2004 2:21 am
Location: Rudy's Bar

Postby Mystery » Mon Dec 03, 2007 10:06 am

You're welcome :)
Have fun using it :D
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

thanks

Postby Crazygamemaker » Tue Dec 04, 2007 2:55 am

Just what I was looking for.
Thank you Mystery! :D
AdvenureMaker is so easy even a caveman can use it!
User avatar
Crazygamemaker
VIP
 
Posts: 278
Joined: Tue Jul 10, 2007 1:40 am
Location: 805,Califas

Postby Chromegloss55 » Sat Dec 08, 2007 3:10 pm

Just an additional little thing (and this has been included in my 100 Visual Basic Techniques), you know when you type into a password box you only see: ***********

Well the code to make that happen uses the PasswordChar property.

This is the code:

TextBoxObject(i).PasswordChar = "*"

At least I think it is. If I'm wrong I'll correct it.
_________________
Finnish Forum
Last edited by Chromegloss55 on Tue Feb 24, 2009 3:08 pm, edited 1 time in total.
Chromegloss55
Forum Master
 
Posts: 630
Joined: Sat Nov 03, 2007 2:49 pm
Location: God Knows!

One Question...

Postby Tony_LaRocca » Sat Feb 23, 2008 12:40 am

This is great- but is there any way to have the password input using the "enter" key rather than having to click on the hotspot? Thanks
User avatar
Tony_LaRocca
Member
 
Posts: 34
Joined: Wed Feb 20, 2008 4:14 am

Postby Mystery » Sat Feb 23, 2008 1:03 am

Unfortunately not to my knowledge.
There is a need for the hotspot to check the entered data.
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

is there any way...

Postby Tony_LaRocca » Sat Feb 23, 2008 3:00 am

How would I go about putting in the possibilities of different answers? I've tried adding other if - then routines, but I must be doing something wrong, because I get an error:

If TextBoxObject(1).Text = "password" Then Action.GoToFrame "room"

If TextBoxObject(1).Text = "pass" Then Message "Could you use more letters, please?"

Else Message "Better luck next time"

End If

The scripting box gives me an "expected end" error. Sometimes, it gives me an "Expected If" error.

Thanks!
User avatar
Tony_LaRocca
Member
 
Posts: 34
Joined: Wed Feb 20, 2008 4:14 am

Never mind, I've sussed it

Postby Tony_LaRocca » Sat Feb 23, 2008 7:46 am

Got it - using the "elseif" command:

If TextBoxObject(1).Text = "Password" Then
Action.GoToFrame "forbidden-room"
Elseif TextBoxObject(1).Text = "open" Then
Message "Think it's that easy?"
Else
Message "Try again!"
End If
User avatar
Tony_LaRocca
Member
 
Posts: 34
Joined: Wed Feb 20, 2008 4:14 am

Postby Mystery » Sun Feb 24, 2008 3:11 am

I'm too late, glad you figured it out meanwhile :)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Chromegloss55 » Tue Feb 26, 2008 7:56 pm

The scripting engine can be so fussy sometimes!

An easiar way to do it would have been to use the Select Case command, it works better than loads of If...Then statements. But whatever gets the job done...
_________________
how does a stock market crash
Last edited by Chromegloss55 on Tue Feb 24, 2009 3:12 pm, edited 1 time in total.
Chromegloss55
Forum Master
 
Posts: 630
Joined: Sat Nov 03, 2007 2:49 pm
Location: God Knows!

Postby Cat » Thu Apr 17, 2008 5:07 am

Thanks so much for this!
Cat
Member
 
Posts: 18
Joined: Thu Mar 06, 2008 8:34 pm

Postby mercedes » Mon May 05, 2008 9:21 pm

This is perfect..


But there is one thing though that I would like to do..for this particular text box..i have yet to try it..im assuming and hoping it will go smoothly..lol..

what i would like to do is add underneath it..
not in the box itself if possible..
i want to add the word "hint" and when they click the word "hint' appears the hint.."Theyre red and they bark..whatever..anything..and it can either go away after a few second or when they leave the screen..and have to click it again..when they come back to it..<<this part doesnt matter..so much.

Is this possible Mystery..? I'm not really sure what its called what im asking for ..i think ive seen it in riddles..but was hoping you could add it in here..? :oops:

any input would be great..I figure i might as well wait to see if this can be done before i add the box..kinda tells me where to add hints else where..lol..if this doesn't work..~

Also why is hotspot over doorknob and not center of door where the code box is..?
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby Mystery » Tue May 06, 2008 6:01 am

Of course you can add a "hint" icon in a hotspot.
Then you need to go to the Hotspot Properties, and choose what should happen when it's clicked (for example a hint message is displayed).


For the doorknob question:
Well it's just an example in the first post, you can put the hotspot whereever you like, and change the script according to your own needs ;)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby mercedes » Tue May 06, 2008 6:06 am

OMG..am i ever a bonehead..that never even occured to me..lol..


i have this code in there now and i keep getting an error..what am i doing wrong..was following a tutorial...i must have typed something wrong..?


Code: Select all
LoadControl TextBoxObject(1)
TextBoxObject(1).Visible = True
TextBoxObject(1).Left = 212*15
TextBoxObject(1).Top = 212*15
TextBoxOjbect(1).Width = 146*15-------------ojbect
TextBoxObject(1).Height = 14*15



edit..never mind i see it..i copied and pasted it..without even thinking it could be spelled wrong..lol..


Im a bit confused now though..ive entered this in as it is.in the frame properties ..and i see that the code you entered starts off with the the code in the frame properties but you enter the answer to end of code..like where u put answer is in the hotspot of doorknob..what do i do..does it matter..?
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby Mystery » Tue May 06, 2008 6:42 am

I'm not quite sure if I understand what you mean mercedes.

You need a hotspot that checks the player's answer (compares password with what the player has entered).
I've chosen for that a hotspot over the doorknob, but you can add any kind of hotspot, for example a "ENTER" icon, "CHECK" icon etc.
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby mercedes » Tue May 06, 2008 6:47 am

ohhhhh..ok..i was basically wondering why it was started in frame properties and ends in the the hotspot over doorknob...but i get it now..basically all that hotspot is there for is to check it.. so this way door either opens or it doesn't saying whatever..i get it. now..

THANK YOU..~! :lol:

first time ive ever done it..so it seemed strange to me..but its like an enter button ..didn't recognize it as checking the answer..sorry about that..~ If you have never done it before..its a bit confusing but i see now what all together purpose of it.


thank you for clearing that up..

I ended up using this code ...was alot easier for me to use and understand..just wanted to know why and what it was i was doing..

could you explain why the word "move" in the code plz..

Also i thought that left top and width and height all applied to the box..the text box but it doesnt..

top and left apply to frame position
height and width apply to text box....

took me a bit of reading to see that ....:) Thanks to Chromeglass for putting that in his tutorial..as well as why the number 15 was in the code ..it's measured in pixels..so * it by 15..aha..lol..

Between all of the coding gurus on this site..I'll get er done..~..

many thanks..~~!@!! :lol:
Last edited by mercedes on Tue May 06, 2008 7:09 am, edited 1 time in total.
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby Mystery » Tue May 06, 2008 6:57 am

Yes, exactly - the hotspot is used to CHECK the answer :D

No need to apologize, it can be pretty difficult to understand for new users. And only if you understand the examples, you will be able to change them according to your own needs.

Glad you have figured out, and understood how this password example works :)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland


Return to Post Your Own Tutorials

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron