Authentication prompt

  • vertigo
    29th Jun 2012 Member 0 Permalink

    Well i have run into problems. I dont know what is wrong with my script! The code is starting to make me feel dizzy. I need to buy computer glasses, but anyways, i scanned through the code and im just frustrated. The first part doesnt even happen. I am annoyed, please help me. The code:

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

    p = pc --password = passwordchange
    x = 50 --this is for the colors at the end.
    y = 100 --this too
    z = 255 --and also this
    n = tpt.get_name() --this gets the user's name
    tpt.message_box("The default password is: Password") --tells you the default password
    s = tpt.input("Authentication required.","Please authenticate that you are "..n,"Password") --asks it
       if s == p --if s is equal to the input password
          then do --then
          c = tpt.input("Change password?","Y/N") --it asks to change password
       end
    end
       
       if s == "Password" and pc == nil --if it is the default pass and pc = nil then let you pass *
          then do
          pc = tpt.input("Password Change.","Enter new password here:"  --prompts you for a new pass
          end
       end
    end
       if s ~= p --if the password is incorrect, display a message saying so.
          then do
          tpt.message_box=("Authentication failed.","Your authentication is incorrect. Try again.")
          os.exit() --then quit when you press OK
       end
    end
       if c == "Y" --checks if you answered Y to the password change.
          then do
          pc = tpt.input("Password Change.","Enter new password here:" --if so it asks for a new password
       end
    end
       function Text()
       tpt.fillrect(237,188,tpt.textwidth("Welcome, "..n.." to The Powder Toy!")+5,13,x,x,x) --making back
       tpt.drawtext(240,191,"Welcome, "..n.." to The Powder Toy!",y,y,z) --adding text
       x=x-.1 --decay rates
       y=y-.2 --more
       z=z-.4 --more
          if z == 0 --delete the box when all color is gone, otherwise it would hide part of the screen.
             then do
             tpt.unregister_step(Text) --same thing going on
          end
       end
    end
    tpt.register_step(Text) --run the function "Text" every frame

    --done

    --***i am not sure if "and" exists. i use it in java, so ya... :/

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

    Why wont it work? Please help me! EDIT-any help? no one?? D:

  • mniip
    5th Jul 2012 Developer 0 Permalink
    remove the lots of then-do
    you can put multiple statements in if-then-end
    you have missed some end's
  • nmd
    5th Jul 2012 Member 0 Permalink
    Apparently vertigo's code is making him dizzy XD
    /pun

    I would say something about while statements and the lack of brackets, but this isn't a java program :/
  • MasterMind555
    5th Jul 2012 Member 0 Permalink

    @vertigo (View Post)

     Your code was full of errors, mostly end statements where there shouldn't be, forgotten closing parentheses and 'then do'. I also noted uncommon indentation.

     

    Here's the revised ( and working ) version: http://pastebin.com/v3xe9NZD

     

    Make sure to carefully read the revised version to learn from your errors

     

    However, I doubt that it does what you want it to do, you might need to revise it.

  • mad-cow
    13th Jul 2012 Member 0 Permalink

    the new password thing what do i enter, this is interesting i could lock my tpt and on properties of the autorun put hide! interesting concept!