Announcement

Collapse
No announcement yet.

Question about Multiple Input Boxes Linked to 1 Submit button

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about Multiple Input Boxes Linked to 1 Submit button

    I almost have this working but I know it's not exactly right. I have 2 input boxes setup that are asking 2 questions, linked to a single submit button. If the 2 questions are answered correctly it gives a Congratulations message and goes to the next page. This part is actually working as intended however if either of the answers are wrong it should pop up a message to that effect. Right now nothing pops up if either input is wrong, what correction do I need to make to my script please?

    Script as it is now:
    Code:
    stAnsw = Input.GetText("Input1");
    stAnsw2 = Input.GetText("Input2");
    if stAnsw == "windsor" then
    if stAnsw2 == "tanzania" then
    Dialog.Message("Congratulations!", "Targets Located", MB_OK, MB_DEFBUTTON1);
    Page.Jump("Page4");
    else
    Dialog.Message("Try Again", "Sorry, your Kung-Fu is Weak", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
    end end

  • #2
    Follow-up, I tried this as well but this allowed the next page to come up with only the "tanzania" question to be correct and not both answers being correct...

    Code:
    stAnsw = Input.GetText("Input1");
    if stAnsw == "windsor" then
    Dialog.Message("Congratulations!", "Target 1 Located", MB_OK, MB_DEFBUTTON1);
    else
    Dialog.Message("Target 1 Is Incorrect", "Try Again", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
    end;
    stAnsw2 = Input.GetText("Input2");
    if stAnsw2 == "tanzania" then
    Dialog.Message("Congratulations!", "Target 2 Located", MB_OK, MB_DEFBUTTON1);
    Page.Jump("Sniper2");
    else
    Dialog.Message("Target 2 Is Incorrect", "Try Again", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
    end
    Also a side question is there a way to make it accept the answer regardless of CAPITALIZATION? Thanks!

    Comment


    • #3
      If the page jumps when there both right you don't need to do anything like this really just do this, Below are 3 little examples for you.

      PHP Code:
      -- Example 1
      TagOne 
      false;

      stAnsw Input.GetText("Input1");
      if 
      stAnsw == "windsor" then
          TagOne 
      true,
      end

      stAnsw2 
      Input.GetText("Input2");
      if 
      stAnsw2 == "tanzania" and TagOne then
          Page
      .Jump("Sniper2");
      else
          
      Dialog.Message("Try Again""It seems you got one of the questions wrong, please try again."MB_OKMB_ICONEXCLAMATIONMB_DEFBUTTON1);
      end

      Dialog
      .Message("Try Again""It seems you got one of the questions wrong, please try again."MB_OKMB_ICONEXCLAMATIONMB_DEFBUTTON1);



      -- 
      Example 2
      stAnsw 
      Input.GetText("Input1");
      stAnsw2 Input.GetText("Input2");
      if 
      stAnsw == "windsor" and stAnsw2 == "tanzania"then
          Page
      .Jump("Sniper2");
      else
          
      Dialog.Message("Try Again""It seems you got one of the questions wrong, please try again."MB_OKMB_ICONEXCLAMATIONMB_DEFBUTTON1);
      end



      -- Example 3
      if Input.GetText("Input1") == "windsor" and Input.GetText("Input2") == "tanzania"then
          Page
      .Jump("Sniper2");
      else
          
      Dialog.Message("Try Again""It seems you got one of the questions wrong, please try again."MB_OKMB_ICONEXCLAMATIONMB_DEFBUTTON1);
      end 
      Plugins or Sources MokoX
      BunnyHop Here

      Comment


      • #4
        OMG I can't believe all I needed was the word "AND" like in your Example #2 Thanks for the response, as u can see I know just enough to barely get by

        By the way I kept messing with it last night and this also worked though I'm sure it's not the "clean" way to do it....Sniper3 being the same page the question is on....


        Code:
        stAnsw = Input.GetText("Input1");
        if stAnsw == "windsor" then
        Dialog.Message("Congratulations!", "Target 1 Located", MB_OK, MB_DEFBUTTON1);
        else
        Dialog.Message("Target 1 Is Incorrect", "Try Again", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
        Page.Jump("Sniper3");
        end;
        stAnsw2 = Input.GetText("Input2");
        if stAnsw2 == "tanzania" then
        Dialog.Message("Congratulations!", "Target 2 Located", MB_OK, MB_DEFBUTTON1);
        Page.Jump("Sniper4");
        else
        Dialog.Message("Target 2 Is Incorrect", "Try Again", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
        Page.Jump("Sniper3");
        end

        Comment


        • #5
          If your going to jump to a page I don't feel you need the dialog box's you could add a simple message on the page your going to, if this is for your project you posted then ya you don't need the dialogs I believe or in my view it will pull the player out of the game two much to see a dialog message.
          Plugins or Sources MokoX
          BunnyHop Here

          Comment


          • #6
            here is a shorted and cleaned up version set isDialog = true if you want the dialog messages, also changes the wording a little

            PHP Code:
            isDialog false -- Change this to true to show the dialogs below.

            if 
            Input.GetText("Input1") == "windsor" and Input.GetText("Input2") == "tanzania" then
                
            if isDialog then
                    Dialog
            .Message("Congratulations!""All targets have been located."MB_OKMB_DEFBUTTON1);
                
            end
                Page
            .Jump("Sniper4");
            else
                if 
            isDialog then
                    Dialog
            .Message("Try Again""Not all targets was located."MB_OKMB_ICONEXCLAMATIONMB_DEFBUTTON1);
                
            end
                Page
            .Jump("Sniper3");
            end 
            Plugins or Sources MokoX
            BunnyHop Here

            Comment


            • #7
              Thanks again for the help, is there a way to set it to accept correct answers regardless of capitalization? For example if someone typed, Windsor, or WINDSOR? I've searched this in the past and didn't really find an answer.

              Comment


              • #8
                Originally posted by Wizaro View Post
                Thanks again for the help, is there a way to set it to accept correct answers regardless of capitalization? For example if someone typed, Windsor, or WINDSOR? I've searched this in the past and didn't really find an answer.
                Yes you can do string lower on Input.GetText("Input1") eg String.Lower(Input.GetText("Input1"))


                Example Update:

                PHP Code:
                isDialog false -- Change this to true to show the dialogs below.

                if 
                String.Lower(Input.GetText("Input1")) == "windsor" and String.Lower(Input.GetText("Input2")) == "tanzania" then
                    
                if isDialog then
                        Dialog
                .Message("Congratulations!""All targets have been located."MB_OKMB_DEFBUTTON1);
                    
                end
                    Page
                .Jump("Sniper4");
                else
                    if 
                isDialog then
                        Dialog
                .Message("Try Again""Not all targets was located."MB_OKMB_ICONEXCLAMATIONMB_DEFBUTTON1);
                    
                end
                    Page
                .Jump("Sniper3");
                end 
                Plugins or Sources MokoX
                BunnyHop Here

                Comment


                • #9
                  Nice job, Rexxy. He could probably also achieve this via pattern-matching, using the appropriate character-classes for upper/lower case.
                  ie.
                  Code:
                   str_windsor = [wW][iI][nN][dD][sS][oO][rR]
                  str_tanzania = [tT][aA][nN][zZ][aA][nN][iI][aA]
                  @Wizaro
                  More on understanding pattern-matching here:

                  Comment


                  • #10
                    Originally posted by BioHazard View Post
                    Nice job, Rexxy. He could probably also achieve this via pattern-matching, using the appropriate character-classes for upper/lower case.
                    ie.
                    Code:
                     str_windsor = [wW][iI][nN][dD][sS][oO][rR]
                    str_tanzania = [tT][aA][nN][zZ][aA][nN][iI][aA]
                    @Wizaro
                    More on understanding pattern-matching here:

                    https://www.fhug.org.uk/wiki/wiki/do...g_lua_patterns
                    That would be kind of pointless tho on resoruces tho, when you can just slower it all to the same type, no point in pattens on this kind of exmaple, I only use pattens is and really neeeded, no point making something that simple that complex if you ask me lol

                    But it would also depend on what you wanted to do.
                    Plugins or Sources MokoX
                    BunnyHop Here

                    Comment


                    • #11
                      Sure, I'd concur with that. Is just one other option, is all.
                      Plus, he'd need to run an s:match or s:gmatch for correct return, anyway.

                      Yep, String.Lower is probably the best choice. The 'ayes' have it!

                      PS.
                      Where ya' been, rexxy? You're too few and far in between these dayz!
                      We miss ya, brother!

                      Comment


                      • #12
                        Originally posted by BioHazard View Post
                        Sure, I'd concur with that. Is just one other option, is all.
                        Plus, he'd need to run an s:match or s:gmatch for correct return, anyway.

                        Yep, String.Lower is probably the best choice. The 'ayes' have it!

                        PS.
                        Where ya' been, rexxy? You're too few and far in between these dayz!
                        We miss ya, brother!
                        I still come here from time to time but I feel I am no longer really a programmer I am unable to keep up with the kool kids, I can't learn another platfrom, it would waste two much of my life, it would be like playing pokemon go lol, I still come here tho, My wife wanted my new app idea it's the only reason why I even bothered, I still make some php to ams apps for fun but nonthing ever worth releasing there all just random ideas.

                        I have never been good as some users here lol
                        Plugins or Sources MokoX
                        BunnyHop Here

                        Comment


                        • #13
                          Originally posted by kingzooly View Post
                          .
                          I still come here from time to time but I feel I am no longer really a programmer...
                          Mmm, on that - let me share some thoughts with you, Rexxy:

                          Don't you dare sell yourself short, buddy. Your long-time experience and contributions to this community are invaluable. And here's a fun FACT for ya: It was YOU who was fundamental in cementing my interest in Lua and in coding in general. I don't expect you'll remember this, but:

                          It was back around 2009, there was one night that you and me and JDog spent collaborating on a project together which evolved into a LogOn app, which you ended up calling HOne_Shark.

                          Now, don't get me wrong, this thing was 90% YOUR work. But we did work on it together. And I had a lot of fun that night. LOL, the booze I was drinking at the time probably had something to do with that - but I do remember it. And it cemented my involvement with the forum. And that was because of you. Do you remember that night? We got stuck at a certain point, and Sakuya dropped in, right out-of-the-blue, with a very cool solution that solved our coding-dilemna. A short time later, HOne_Shark was borne.

                          The proof of the pudding is in the eating, baby. Check it out:



                          That's your work, right there! And you're kindness to involve me in it, was what was fundamental in my cementing my involvement in this community. I was gone for a long time after the infamous 2011/2012 purge. But I'm back, baby! Reborne as BioHazard. Never doubt your influence, Rexxy - a small kindness echoes down over the years, a long, long way. And your presence here IS appreciated!

                          PS.
                          Originally posted by kingzooly View Post
                          ... unable to keep up with the kool kids ...
                          And fcuk the cool kids! Never did like 'em much, anyway!

                          Comment


                          • #14
                            @Wizaro

                            Sorry for inadvertently hijacking your thread, buddy.

                            Comment


                            • #15
                              No apologies necessary! I appreciate the help and glad I could facilitate u guys catching up Thanks to u both for the CAPS answer. I still have a long way to go, but I try really hard to figure it out on my own before begging for help heh.

                              Comment

                              Working...
                              X