Untitled

mail@pastecode.io avatar
unknown
lua
15 days ago
894 B
4
Indexable
Never
function getMatrixPositions(centerPosition, area)

    local xLength = #area[1]
    local yLength = #area

    local xCenter = 0
    local yCenter = 0

    for x = 1, xLength do
        for y = 1, yLength do
            if area[y][x] == 2 or area[y][x] == 3 then

                xCenter = x
                yCenter = y

                break
            end
        end
    end

    local positions = {}
    if xCenter ~= 0 and yCenter ~= 0 then
        for x = 1, xLength do
            for y = 1, yLength do
                if area[y][x] == 1 or area[y][x] == 3 then
                    positions[#positions + 1] = Position(
                        centerPosition.x - (xCenter - x), 
                        centerPosition.y - (yCenter - y), 
                        centerPosition.z
                    )
                end
            end
        end
    end
    
    return positions
end
Leave a Comment