Noob logic help

Hey,

So I need some help with what is simple logic, I have done it before but I think my brain is fried from months of game development.

I have a uniform grid, inside the uniform grid are custom widget buttons. The buttons will represent rooms.

I only want the rooms next to the player location to be selectable, so how does one go about telling a button inside a uniform grid what it is next to? The grid is in 4 directions at one point…so I can’t just loop through the array and say enable if you are -1 and +1 of the current array position. As that only does left and right.

I should say the number of rooms is random, so I would never be able to say -8 and +8 or anything like that to work out up and down as the number will vary every play through.

It is probably something really dumb and straight forward…but the uniform grid is adding an extra dimension of fuzz in my head.

Any suggestions welcomed.

Thanks

It was as simple as my current location + or - the number of columns in the grid. (factoring in the 0 base nature of an array)