Non-threaded

Forums » Newbie Central » Read Thread

Introduce yourself and get to know the community.

Passwords?

15 years ago

Hi,

I'm working on my first story and I was wondering is it possible for me to put in a password which the reader must get correct before advancing to the next area?

I've had a look through the various guides however I can't seem to find what I'm looking for. Thanks for any help in advance

Marsden.

Passwords?

15 years ago

Hi Marsden,

Welcome to the site! I remember this question from a long time back - not your fault that you couldn't find it, sort of buried in the Advanced Editor forum - and Tsmpaul had written a solution, which I've included below.

TSMPAUL:

"Doh! I deleted it at some point. Anyhow, off the top of my head, this is basically how to do it:

STEP ONE

Create these variables:

%LETTER1, %LETTER2, %LETTER3, and however many letters long your password will be.
Set all of those letter variables to the number "0".

Also create a variable called %CURRENT which keeps track of how many letters they have entered for their password. Set it to "0".

STEP TWO

Create as many links as you want, having them point to this same page the links are on.
Links might be "A", "B", "C", "D", etc... You don't have to go all the way to "Z", but you can if you want to. A lot of password systems only use letters "A" through to "E".

When the link is clicked on, you create a script that moves to the next letter (changing %CURRENT) then assigns a numeric value for that password letter. The number you assign represents which letter they are typing. A = 1, B = 2, C = 3, D = 4, and so forth.

So, if you only have a three letter password, for the link "A" you might have a script that looks like this:

----------------------------------------------

%CURRENT := %CURRENT + 1

IF %CURRENT = 1 THEN
BEGIN
   %LETTER1 := 1
END

IF %CURRENT = 2 THEN
BEGIN
   %LETTER2 := 1
END

IF %CURRENT = 3 THEN
BEGIN
   %LETTER3 := 1
END

----------------------------------------------

STEP THREE

Now you need to create your page script to display what password letters have been selected. Basically, it runs through the letters the player is entering, checking their variables to see if they are above zero, "0". If they are above "0" then the player has clicked on a letter link, so you need to check which number value the letter has, and assign the letter for that number. So, the page script for a three letter password, using only the letters A and B to make your password:

----------------------------------------------------------------

$PAGETEXT := "Please enter your password: "

IF %LETTER1 > 0 THEN
BEGIN
   IF %LETTER1 = 1 THEN $PAGETEXT := $PAGETEXT + "A"
   IF %LETTER1 = 2 THEN $PAGETEXT := $PAGETEXT + "B"
END

IF %LETTER2 > 0 THEN
BEGIN
   IF %LETTER2 = 1 THEN $PAGETEXT := $PAGETEXT + "A"
   IF %LETTER2 = 2 THEN $PAGETEXT := $PAGETEXT + "B"
END

IF %LETTER3 > 0 THEN
BEGIN
   IF %LETTER3 = 1 THEN $PAGETEXT := $PAGETEXT + "A"
   IF %LETTER3 = 2 THEN $PAGETEXT := $PAGETEXT + "B"
END

--------------------------------------------------------------

STEP FOUR

Finally, you need to make the links that let the user try out the password and see if it works. It might be called "Try This Password" or something. It directs the user to a password failure page. However, the link's script changes the destination of the link to the successful password's page if the password is right.

If the password was a three letter password, using just A's and B's, for example ABA, and the destination page number for the correct password was 6, then the script would look like this:

-----------------------------------------

IF %LETTER1 = 1 THEN
BEGIN
    IF %LETTER2 = 2 THEN
    BEGIN
        IF %LETTER3 = 1 THEN
        BEGIN
             $DEST := @P6
        END
    END
END

---------------------------------------

You might also like to create another link that allows the user to erase the letters they have typed so far. Simply make that link set %CURRENT back to zero, and set all the %LETTER variables to zero.

Oh, and you might want to set a visible restriction on your Letter Links, so that they don't appear when %CURRENT passes the length of your password. Ie, if your password is 3 letters long, then make it so the links don't show if %CURRENT = 4.

I think that's about it. If I've made any mistakes, I'm sure other scripters can correct it in a reply post :)"

Passwords?

15 years ago

Thanks very much Madglee.