-1
        if event.type == MOUSEBUTTONUP:
            mouseX, mouseY=event.pos
            if warsaw_button.collidepoint(mouseX,mouseY):
                choices = ["build a structure", "acquire units", "destroy structure", "launch from silo"]
                choicebox("What do you want to do commander?", warsaw_name, choices)
                if choicebox == choices[0]:
                    msgbox("you want to build a structure")
                elif choicebox == choices[1]:
                    msgbox("you want to acquire more units")
                elif choicebox == choices[2]:
                    msgbox("you want to destroy structures you built")
                elif choicebox == choices[3]:
                    msgbox("you want to launch missile from a silo")

When ever I choose something, the msgbox just wouldn't come out

  • The *`choicebox` function itself* is never going to be equal to a string. You need to store the result of *calling* the function in a variable, then test that variable against the strings. – jasonharper Dec 14 '20 at 17:58

1 Answers1

0

You are testing the choicebox function against your strings. Instead, test the result of the choicebox function against your strings. To make it cleaner, assign it to a choice variable.

        if event.type == MOUSEBUTTONUP:
            mouseX, mouseY=event.pos
            if warsaw_button.collidepoint(mouseX,mouseY):
                choices = ["build a structure", "acquire units", "destroy structure", "launch from silo"]
                choice = choicebox("What do you want to do commander?", warsaw_name, choices)
                if choice == choices[0]:
                    msgbox("you want to build a structure")
                elif choice == choices[1]:
                    msgbox("you want to acquire more units")
                elif choice == choices[2]:
                    msgbox("you want to destroy structures you built")
                elif choice == choices[3]:
                    msgbox("you want to launch missile from a silo")
mazore
  • 984
  • 5
  • 11