I am trying to create a function I can use in Blueprint. Basically I want to loop through an Array and output the index and the item (name) I am pointing at (for the beginning at least).
However, the Array elements are structs and I realized that the syntax must be quite different than if it held an AActor for example.
I keep getting compiler errors, no matter if I dereference with * or got for the address with &. I am getting confused. Do I even need the & in front of the method variables?
You can still used ranged-for loops and get an index, granted it requires an extra bit of code.
int32 Index = INDEX_NONE;
for (const FItem& Item : Items)
{
Index++;
//WhateverHere
}
or you can use traditional for loop
for (int32 I = 0; I < Items.Num(); ++i)
{
Items[i];
}
thank you. Yes, if you know how to handle them they are easy. I just have to do a few
more exercises.
The background is that I created an inventory system but whenever I remove an item, all items
with the same database ID are deleted. I think it has to do with the loop currently used vs
a reverse loop which I should be using I think.