Hello everyone,
I’ve been having some issues with this loop I’m trying to make. This loop activates when the amount of items that have to be added to the inventory surpasses the stack size for said item.
IFor each loop, it should create a full stack of that item and decrease the amount to add to the inventory by the stack’s size amount. It should repeat until the amount to add to the inventory is less than the stack size, in which case it should add an additional stack with the items that remain.
The problem is that the loop gives out an infinite repetition error, and I can’t seem to find where that error is.
Can you help me out on this?
The loop node I mentioned is higlighted in yellow.
A for loop is used when you know how many iterations of that loop you will need.
I need the loop to continue as long as the variable is above zero and below a given “stack” size, and every iteration of the loop reduces that variable’s value by a “stack” amount
I don’t think the for loop would be useful here, since I can’t put a specific number of iterations, the value of “stack” is variable depending on the item type, as well as the amount to add/subtract from the inventory
Exactly! You should use a for loop with break for such a task. Using a while loop is definitely not the way to go here. You can set the last index as whatever’s the max possible iteration is in your specific task and break when your desired condition is met.
Oh my god. Thank you so much. Yesterday I was struggling a lot with this, but as soon as I implemented this logic it worked. Im infinitely grateful for the help.