if(mouseIsOver(gogglesBtnP1) && mouseWentDown("leftButton")) {
    switch(itemsP1[0]) {
        case "goggles": itemsP1[0] = "gogglesEquipped"; gogglesBtnP1.setAnimation("equipBtn"); break;
        case "gogglesEquipped": itemsP1[0] = "goggles"; gogglesBtnP1.setAnimation("equipBtn"); break;
        default: if(eggbucksP1 >= 500) { itemsP1[0] = "goggles"; eggbucksP1 -= 500; } break;
    }
}
textSize(12);
textAlign(CENTER, CENTER);
// with this addition you should be able to get your text centered right the first time
text((itemsP1[0] === "goggles" ? "Equip": itemsP1[0] === "gogglesEquipped" ? "Unequip": ""), 42, 94);

not sure if you wanted to keep all the original code but i may have removed a few things, you could just add a setTimeout the switch statement if that is important i figured you put those in so it wouldn't trigger the other if statements

can you explain the ? operator thing?

    the text center thing has a problem of where it wont center properly

    pluto The ? operator is like a condensed if/else statement.

    If I had this code:

    var num = 1;
    num ? console.log("This statement is true") : console.log("This statement is false");

    It would return "This statement is true" because it's the same as:

    var num = 1;
    if(num){
        console.log("This statement is true");
    }else {
        console.log("This statement is false");
    }

    You can also chain multiple of these statements together:

    var age = 22;
    age < 18 ? console.log("You are a Child") : age < 65 ? console.log("You are an adult") : console.log("You are a senior");

    This would return "You are an adult". This statement is the same as:

    var age = 22;
    if(age < 18){
        console.log("You are a child");
    }else {
         if(age < 65){
             console.log("You are an adult");
         }else {
             console.log("You are a senior");
         }
    }

    As you can see, it decreased the number of lines from 10 all the way down to just 2.

    Unlike if/else however, the ? statements return values that you can use in your program.

    For example, I can set variables to whatever the statement returns; In this small bit of code, it checks if you're a kid or not and sets the price accordingly.

    var age = 9;
    var ticketPrice = age < 18 ? "$5.00" : "$10.00";
    console.log(ticketPrice);
    //Returns $5.00

    If you need more help with it there's some topics abt it on StackOverflow and on google, here's some documentation on it https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

    • -wyi replied to this.

      The line (itemsP1[0] === "goggles" ? "Equip": itemsP1[0] === "gogglesEquipped" ? "Unequip": "") in Varrience's code basically means:

      if(itemsP1[0] === "goggles"){
          return "Equip";
      }else {
          if(itemsP1[0] === "gogglesEquipped"){
              return "Unequip";
          } else return "";
      }

      Just an easy way not to scar your eyes with an excessive amount of if else statements

        Letti42 hey. do you know how to put themes in a shop in a brendan/wutadam chat?

        • -wyi replied to this.

          -wyi Or how to make it so that you already have access to them without buying when you join?

            Letti42 how come i always figure it out by myself after asking

            • -wyi replied to this.

              -wyi Like when you leave you have whatever the user saved? You would probably need to use user ids and save it to a record or key value.

              • -wyi replied to this.

                -wyi What are you trying to make

                • -wyi replied to this.

                  -wyi I mean yeah but like how did Adam do it? what'd he type in the debug console

                  He didn't.. type anything into a console..? He coded it into the app itself

                  • -wyi replied to this.

                    Letti42 yeah, but to update the themes in the shop.

                    • -wyi replied to this.

                      -wyi he told me once, but I forgot most of it.

                      • -wyi replied to this.

                        -wyi I'm kinda stupid sometimes...

                        Chat