Getting ItemDefinitions list of strings attribute problem

desukarhu

Member
Hey,

I asked about this on discord earlier, but I simply can't get it to work and I don't understand why.

So I have equipment that have array of ItemDefinitions that represent slotted gems. The slots can be null.
Then on the gems I have a list of strings to represent the attribute bonuses the gems would give. I'm trying to loop through them on my custom Equipper script, but the list of strings is always empty.
Here's a part of my code:

Code:
      Attribute<ItemDefinition []> gemSlots = item.GetAttribute<Attribute<ItemDefinition []>>("Gem Slots");

      if (gemSlots != null && gemSlots.GetValue() != null) {

        ItemDefinition [] gemSlotList = gemSlots.GetValue();

        for (int i = 0; i < gemSlotList.Length; i++) {
          if (gemSlotList [i] == null) {
            continue;
          }

          Debug.Log("Slotted gem name: " + gemSlotList [i].name); // << This prints out the correct gem name
          Attribute<List<string>> gemSlotModifiers = gemSlotList [i].GetAttribute<Attribute<List<string>>>("Modifiers");
          List<string> gemSlotModifiersList = modifiers.GetValue();
          Debug.Log("Modifier amount: " + gemSlotModifiersList.Count); // << This is the problem, the count is always 0

          Attribute<Rarity> gemRarityTest = gemSlotList [i].GetAttribute<Attribute<Rarity>>("Rarity");
          Debug.Log("Gem rarity: " + gemRarityTest.GetValue()); // << This prints out the correct overriden rarity attribute, so other attributes do work
        }
      }


Edit: 5 minutes after posting this I noticed my mistake. Nevermind lmao. "List<string> gemSlotModifiersList = modifiers.GetValue();" I'm getting the value from the wrong attribute. Should be gemSlotModifiers.GetValue().
It works now.
 
Top