diff --git a/ModuleScripts/Grids.lua b/ModuleScripts/Grids.lua index b0f6388..8662248 100644 --- a/ModuleScripts/Grids.lua +++ b/ModuleScripts/Grids.lua @@ -145,7 +145,7 @@ local function generateRandomPath(grid: grid & Grid, startIndex: numb table.insert(directions, {node = forwardNode, weight = 1.2}) end - for i, direction in ipairs(directions) do + for i, direction in directions do local distance = math.abs(direction.node - endIndex) direction.weight = direction.weight / (distance + 1) end @@ -153,7 +153,7 @@ local function generateRandomPath(grid: grid & Grid, startIndex: numb if #directions > 0 then local totalWeight = 0 - for _, direction in ipairs(directions) do + for _, direction in directions do totalWeight = totalWeight + direction.weight end @@ -161,7 +161,7 @@ local function generateRandomPath(grid: grid & Grid, startIndex: numb local accumulatedWeight = 0 local selectedNode - for _, direction in ipairs(directions) do + for _, direction in directions do accumulatedWeight = accumulatedWeight + direction.weight if rand <= accumulatedWeight then selectedNode = direction.node