I’m a new developer, working on learning UE4 while I have some free time, and while the engine has been incredibly robust and a lot of fun to work with, I’ve finally hit a bug (?) that defies explanation, so I need help.
I’m trying to set up an inventory system, with the goal of being able to set it up for drag-and-drop of multi-tile items. The base of the inventory system is a grid of item slots. As part of the code to make this happen, I have a function called IsSpaceEmpty that takes a couple things as input and checks against an array of integers to see if something is already there or not.
SO. The expected functionality here is:
For Loop starts at 17*, outputs index 17*, sends it through modulo grid width to return 5
Value : 5
Min : 5
Max : 7
Good so far.
Array contains item goes:
Do I have a 17*?
No, I do not have a 17.
And operator says false, because CONTAINS said false, so go next loop
Loop increments one, is at 18, sends through modulo grid width to return 6
Value : 6
Do I have an 18*?
Yes, I do have an 18.
And here’s where it goes to hell.
We go through the AND, and through the true of branch, and return FALSE and SIX.
we return SIX.
WHYYYY IS IT SIXXXX
Melorama aside, that loop seems to range between 5 and 14 regardless of input. One of the first functions of the For Loop is to store its input, and I have verified that in this case the input is 17 via print string. Also verified that the integer going into both CONTAINS and the return node are 6 (or 5) via printstring.
Also, for whatever reason that ArrayToAccess says it has no values in debug, though I know it does. Or assume it has to. Or something.
*None of these were true. The for loop starts at 5, and checks 5 against ArraytoCheck, which does -not- contain a 5, though it does contain a 6.
-EDIT- Ahhhhh nevermind. As it usually is, there was a stupid error. The for loop that starts this was receiving an incorrect value for the end of the loop, so it was starting the loop at 5 to 14 AND 17 to 0, which was just ending the loop immediately, and leaving me with the returned 6 printed from the previous execution of the loop.