- local positions = {
- { x = 0, y = -1 }, -- top
- { x = -1, y = 0 }, -- left
- { x = 0, y = 1 }, -- bottom
- { x = 1, y = 0 }, -- right
- }
-
- if includeDiagonals then
- local diagonalMovements = {
- { x = -1, y = -1 }, -- top left
- { x = 1, y = -1 }, -- top right
- { x = -1, y = 1 }, -- bot left
- { x = 1, y = 1 }, -- bot right
- }
-
- for _, value in ipairs(diagonalMovements) do
- table.insert(positions, value)
- end
+ local positions = {}
+
+ for x = -1, 1 do
+ for y = -1, 1 do
+ for z = -1, 1 do
+ local a = math.abs(x) + math.abs(y) + math.abs(z)
+
+ if a ~= 0 and includeDiagonals or a == 1 then
+ table.insert(positions, {x = x, y = y, z = z})
+ end
+ end
+ end