Array length

Started by nightmarer, Thu 08/04/2021 22:42:52

Previous topic - Next topic

nightmarer

Hello.

I would like to transfer all the items from one character to another character which is going to be the player.ç
I was trying to create a for to transfer them from one to another, but I don't know which property gets the number of that array

Code: ags
  for(i = 1, i < CharacterA.InventoryQuantity[].length(), i++) {
    CharacterB.InventoryQuantity[i] = CharacterA.InventoryQuantity[i]; 
  }


Thank you.

Crimson Wizard

It's Game.InventoryItemCount in that case.

In general, AGS script does not support getting length from arrays themselves, so there must be separate property or constant for built-in arrays, and length stored in a separate variable for user arrays.

nightmarer

Thank you. If someone needs something similar this is how it worked for me.
Code: ags
 
int i; 
for(i = 1; i < Game.InventoryItemCount; i++) {
   CharacterB.InventoryQuantity[i] = CharacterA.InventoryQuantity[i]; 
}
UpdateInventory();
 

SMF spam blocked by CleanTalk