• Question
  • how do you check if you already have an object equipped already

the title name is really self-explanatory

Can you please provide some code so I can provide a relevant response?

You could just make a starter property.
//After creating the sprite
`
sprite.equipped = {
//Change this everytime the player changes to something else
description: 'Name of weapon'
//Add some more properties, like what damage is dealt, recoil, stuff like that
}

if(this.equipped.description === 'weapon you're looking for'){
execute the code
}
`

    ASmartCoder i kinda meant like a system of where it can check if you have more than 1 item so that only 1 item can be equipped

      pluto then just make a variable that holds the item you're... well, holding. then, check if the variable is undefined.

      basically i just want it so that multiple items cannot be equipped; only one.

      You could make a big sourcebook variable that would be an object, listing every item and its properties in a subobject. You could then refer to them later.

      var equippedItem = null;
      
      if(userEquipsItem && !equippedItem){//if new item is equipped and there isnt already one equipped
          equippedItem = that_item
      }
      if(userUnequipsItem){
          equippedItem = null;
      }

        ASmartCoder Null is easier to understand. If anything, making it an empty string would make it even worse

        Letti42 sorry if this is extra, but they must have an object with them at all times (they shall not have no object, there has to be one), so how do i make a system like that?

          pluto so you want to do OOP? your post isn't exactly clear on your intentions but i'll assume you want a way of constructing a class. in that case you'll need to setup something like this

          var Car = (function() { /** @class */
           function Car(name, brand, fuel, mileage, economy) {
            this.name = name;
            this.brand = brand;
            this.fuel = fuel;
            this.mileage = milage;
            this.fuelEconomy = economy;
           }
          return Car;
          })();
          // invoke a class here
          var car = new Car("Honda Civic", "Honda", 15, 53429, 30);

          bro got that Honda Civic

          Chat